<!doctype html><html lang="en">
 <head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <meta content="#3c790a" name="theme-color">
  <title>Encoding Standard</title>
  <link crossorigin href="https://resources.whatwg.org/spec.css" rel="stylesheet">
  <link crossorigin href="https://resources.whatwg.org/standard.css" rel="stylesheet">
  <link crossorigin href="https://resources.whatwg.org/standard-shared-with-dev.css" rel="stylesheet">
  <link crossorigin href="https://resources.whatwg.org/logo-encoding.svg" rel="icon">
<script async crossorigin src="https://resources.whatwg.org/file-issue.js"></script>
<script async crossorigin src="https://resources.whatwg.org/commit-snapshot-shortcut-key.js"></script>
  <link crossorigin href="visualization-colors.css" rel="stylesheet">
<style>/* style-dfn-panel */

.dfn-panel {
    position: absolute;
    z-index: 35;
    height: auto;
    width: -webkit-fit-content;
    width: fit-content;
    max-width: 300px;
    max-height: 500px;
    overflow: auto;
    padding: 0.5em 0.75em;
    font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
    background: #DDDDDD;
    color: black;
    border: outset 0.2em;
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: black; }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0; }
.dfn-panel li { list-style: inside; }
.dfn-panel.activated {
    display: inline-block;
    position: fixed;
    left: .5em;
    bottom: 2em;
    margin: 0 auto;
    max-width: calc(100vw - 1.5em - .4em - .5em);
    max-height: 30vh;
}

.dfn-paneled { cursor: pointer; }
</style>
 <body class="h-entry status-LS">
  <div class="head">
   <p data-fill-with="logo"><a class="logo" href="https://whatwg.org/"> <img alt="WHATWG" crossorigin height="100" src="https://resources.whatwg.org/logo-encoding.svg"> </a> </p>
   <hgroup>
    <h1 class="p-name no-ref" id="title">Encoding</h1>
    <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Living Standard — Last Updated <time class="dt-updated" datetime="1970-01-01">1 January 1970</time></span></h2>
   </hgroup>
   <div data-fill-with="spec-metadata">
    <dl>
     <dt>Participate:
     <dd><a href="https://github.com/whatwg/encoding">GitHub whatwg/encoding</a> (<a href="https://github.com/whatwg/encoding/issues/new">new issue</a>, <a href="https://github.com/whatwg/encoding/issues">open issues</a>)
     <dd><a href="https://wiki.whatwg.org/wiki/IRC">IRC: #whatwg on Freenode</a>
     <dt>Commits:
     <dd><a href="https://github.com/whatwg/encoding/commits">GitHub whatwg/encoding/commits</a>
     <dd>[SNAPSHOT-LINK]
     <dd><a href="https://twitter.com/encodings">@encodings</a>
     <dt>Tests:
     <dd><a href="https://github.com/web-platform-tests/wpt/tree/master/encoding">web-platform-tests encoding/</a> (<a href="https://github.com/web-platform-tests/wpt/labels/encoding">ongoing work</a>)
     <dt>Translations <small>(non-normative)</small>:
     <dd><span title="Japanese"><a href="https://triple-underscore.github.io/Encoding-ja.html" hreflang="ja" lang="ja" rel="alternate">日本語</a></span>
    </dl>
   </div>
   <div data-fill-with="warning"></div>
  </div>
  <div class="p-summary" data-fill-with="abstract">
   <h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
   <p>The Encoding Standard defines encodings and their JavaScript API.</p>
  </div>
  <nav data-fill-with="table-of-contents" id="toc">
   <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
   <ol class="toc" role="directory">
    <li><a href="#preface"><span class="secno">1</span> <span class="content">Preface</span></a>
    <li><a href="#security-background"><span class="secno">2</span> <span class="content">Security background</span></a>
    <li><a href="#terminology"><span class="secno">3</span> <span class="content">Terminology</span></a>
    <li>
     <a href="#encodings"><span class="secno">4</span> <span class="content">Encodings</span></a>
     <ol class="toc">
      <li><a href="#encoders-and-decoders"><span class="secno">4.1</span> <span class="content">Encoders and decoders</span></a>
      <li><a href="#names-and-labels"><span class="secno">4.2</span> <span class="content">Names and labels</span></a>
      <li><a href="#output-encodings"><span class="secno">4.3</span> <span class="content">Output encodings</span></a>
     </ol>
    <li><a href="#indexes"><span class="secno">5</span> <span class="content">Indexes</span></a>
    <li><a href="#specification-hooks"><span class="secno">6</span> <span class="content">Hooks for standards</span></a>
    <li>
     <a href="#api"><span class="secno">7</span> <span class="content">API</span></a>
     <ol class="toc">
      <li><a href="#interface-mixin-textdecodercommon"><span class="secno">7.1</span> <span class="content">Interface mixin <code class="idl"><span>TextDecoderCommon</span></code></span></a>
      <li><a href="#interface-textdecoder"><span class="secno">7.2</span> <span class="content">Interface <code class="idl"><span>TextDecoder</span></code></span></a>
      <li><a href="#interface-mixin-textencodercommon"><span class="secno">7.3</span> <span class="content">Interface mixin <code class="idl"><span>TextEncoderCommon</span></code></span></a>
      <li><a href="#interface-textencoder"><span class="secno">7.4</span> <span class="content">Interface <code class="idl"><span>TextEncoder</span></code></span></a>
      <li><a href="#interface-mixin-generictransformstream"><span class="secno">7.5</span> <span class="content">Interface mixin <code class="idl"><span>GenericTransformStream</span></code></span></a>
      <li><a href="#interface-textdecoderstream"><span class="secno">7.6</span> <span class="content">Interface <code class="idl"><span>TextDecoderStream</span></code></span></a>
      <li><a href="#interface-textencoderstream"><span class="secno">7.7</span> <span class="content">Interface <code class="idl"><span>TextEncoderStream</span></code></span></a>
     </ol>
    <li>
     <a href="#the-encoding"><span class="secno">8</span> <span class="content">The encoding</span></a>
     <ol class="toc">
      <li>
       <a href="#utf-8"><span class="secno">8.1</span> <span class="content">UTF-8</span></a>
       <ol class="toc">
        <li><a href="#utf-8-decoder"><span class="secno">8.1.1</span> <span class="content">UTF-8 decoder</span></a>
        <li><a href="#utf-8-encoder"><span class="secno">8.1.2</span> <span class="content">UTF-8 encoder</span></a>
       </ol>
     </ol>
    <li>
     <a href="#legacy-single-byte-encodings"><span class="secno">9</span> <span class="content">Legacy single-byte encodings</span></a>
     <ol class="toc">
      <li><a href="#single-byte-decoder"><span class="secno">9.1</span> <span class="content">single-byte decoder</span></a>
      <li><a href="#single-byte-encoder"><span class="secno">9.2</span> <span class="content">single-byte encoder</span></a>
     </ol>
    <li>
     <a href="#legacy-multi-byte-chinese-(simplified)-encodings"><span class="secno">10</span> <span class="content">Legacy multi-byte Chinese (simplified) encodings</span></a>
     <ol class="toc">
      <li>
       <a href="#gbk"><span class="secno">10.1</span> <span class="content">GBK</span></a>
       <ol class="toc">
        <li><a href="#gbk-decoder"><span class="secno">10.1.1</span> <span class="content">GBK decoder</span></a>
        <li><a href="#gbk-encoder"><span class="secno">10.1.2</span> <span class="content">GBK encoder</span></a>
       </ol>
      <li>
       <a href="#gb18030"><span class="secno">10.2</span> <span class="content">gb18030</span></a>
       <ol class="toc">
        <li><a href="#gb18030-decoder"><span class="secno">10.2.1</span> <span class="content">gb18030 decoder</span></a>
        <li><a href="#gb18030-encoder"><span class="secno">10.2.2</span> <span class="content">gb18030 encoder</span></a>
       </ol>
     </ol>
    <li>
     <a href="#legacy-multi-byte-chinese-(traditional)-encodings"><span class="secno">11</span> <span class="content">Legacy multi-byte Chinese (traditional) encodings</span></a>
     <ol class="toc">
      <li>
       <a href="#big5"><span class="secno">11.1</span> <span class="content">Big5</span></a>
       <ol class="toc">
        <li><a href="#big5-decoder"><span class="secno">11.1.1</span> <span class="content">Big5 decoder</span></a>
        <li><a href="#big5-encoder"><span class="secno">11.1.2</span> <span class="content">Big5 encoder</span></a>
       </ol>
     </ol>
    <li>
     <a href="#legacy-multi-byte-japanese-encodings"><span class="secno">12</span> <span class="content">Legacy multi-byte Japanese encodings</span></a>
     <ol class="toc">
      <li>
       <a href="#euc-jp"><span class="secno">12.1</span> <span class="content">EUC-JP</span></a>
       <ol class="toc">
        <li><a href="#euc-jp-decoder"><span class="secno">12.1.1</span> <span class="content">EUC-JP decoder</span></a>
        <li><a href="#euc-jp-encoder"><span class="secno">12.1.2</span> <span class="content">EUC-JP encoder</span></a>
       </ol>
      <li>
       <a href="#iso-2022-jp"><span class="secno">12.2</span> <span class="content">ISO-2022-JP</span></a>
       <ol class="toc">
        <li><a href="#iso-2022-jp-decoder"><span class="secno">12.2.1</span> <span class="content">ISO-2022-JP decoder</span></a>
        <li><a href="#iso-2022-jp-encoder"><span class="secno">12.2.2</span> <span class="content">ISO-2022-JP encoder</span></a>
       </ol>
      <li>
       <a href="#shift_jis"><span class="secno">12.3</span> <span class="content">Shift_JIS</span></a>
       <ol class="toc">
        <li><a href="#shift_jis-decoder"><span class="secno">12.3.1</span> <span class="content">Shift_JIS decoder</span></a>
        <li><a href="#shift_jis-encoder"><span class="secno">12.3.2</span> <span class="content">Shift_JIS encoder</span></a>
       </ol>
     </ol>
    <li>
     <a href="#legacy-multi-byte-korean-encodings"><span class="secno">13</span> <span class="content">Legacy multi-byte Korean encodings</span></a>
     <ol class="toc">
      <li>
       <a href="#euc-kr"><span class="secno">13.1</span> <span class="content">EUC-KR</span></a>
       <ol class="toc">
        <li><a href="#euc-kr-decoder"><span class="secno">13.1.1</span> <span class="content">EUC-KR decoder</span></a>
        <li><a href="#euc-kr-encoder"><span class="secno">13.1.2</span> <span class="content">EUC-KR encoder</span></a>
       </ol>
     </ol>
    <li>
     <a href="#legacy-miscellaneous-encodings"><span class="secno">14</span> <span class="content">Legacy miscellaneous encodings</span></a>
     <ol class="toc">
      <li>
       <a href="#replacement"><span class="secno">14.1</span> <span class="content">replacement</span></a>
       <ol class="toc">
        <li><a href="#replacement-decoder"><span class="secno">14.1.1</span> <span class="content">replacement decoder</span></a>
       </ol>
      <li>
       <a href="#common-infrastructure-for-utf-16be-and-utf-16le"><span class="secno">14.2</span> <span class="content">Common infrastructure for <span>UTF-16BE</span> and <span>UTF-16LE</span></span></a>
       <ol class="toc">
        <li><a href="#shared-utf-16-decoder"><span class="secno">14.2.1</span> <span class="content">shared UTF-16 decoder</span></a>
       </ol>
      <li>
       <a href="#utf-16be"><span class="secno">14.3</span> <span class="content">UTF-16BE</span></a>
       <ol class="toc">
        <li><a href="#utf-16be-decoder"><span class="secno">14.3.1</span> <span class="content">UTF-16BE decoder</span></a>
       </ol>
      <li>
       <a href="#utf-16le"><span class="secno">14.4</span> <span class="content">UTF-16LE</span></a>
       <ol class="toc">
        <li><a href="#utf-16le-decoder"><span class="secno">14.4.1</span> <span class="content">UTF-16LE decoder</span></a>
       </ol>
      <li>
       <a href="#x-user-defined"><span class="secno">14.5</span> <span class="content">x-user-defined</span></a>
       <ol class="toc">
        <li><a href="#x-user-defined-decoder"><span class="secno">14.5.1</span> <span class="content">x-user-defined decoder</span></a>
        <li><a href="#x-user-defined-encoder"><span class="secno">14.5.2</span> <span class="content">x-user-defined encoder</span></a>
       </ol>
     </ol>
    <li><a href="#browser-ui"><span class="secno">15</span> <span class="content">Browser UI</span></a>
    <li><a href="#implementation-considerations"><span class="secno"></span> <span class="content">Implementation considerations</span></a>
    <li><a href="#acknowledgments"><span class="secno"></span> <span class="content">Acknowledgments</span></a>
    <li>
     <a href="#section-index"><span class="secno"></span> <span class="content">Index</span></a>
     <ol class="toc">
      <li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
      <li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
     </ol>
    <li>
     <a href="#references"><span class="secno"></span> <span class="content">References</span></a>
     <ol class="toc">
      <li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
      <li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
     </ol>
    <li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a>
   </ol>
  </nav>
  <main>
   <h2 class="heading settled" data-level="1" id="preface"><span class="secno">1. </span><span class="content">Preface</span><a class="self-link" href="#preface"></a></h2>
   <p>The UTF-8 encoding is the most appropriate encoding for interchange of Unicode, the
universal coded character set. Therefore for new protocols and formats, as well as
existing formats deployed in new contexts, this specification requires (and defines) the
UTF-8 encoding. </p>
   <p>The other (legacy) encodings have been defined to some extent in the past. However,
user agents have not always implemented them in the same way, have not always used the
same labels, and often differ in dealing with undefined and former proprietary areas of
encodings. This specification addresses those gaps so that new user agents do not have to
reverse engineer encoding implementations and existing user agents can converge. </p>
   <p>In particular, this specification defines all those encodings, their algorithms to go
from bytes to scalar values and back, and their canonical names and identifying labels.
This specification also defines an API to expose part of the encoding algorithms to
JavaScript. </p>
   <p>User agents have also significantly deviated from the labels listed in the <a href="https://www.iana.org/assignments/character-sets/character-sets.xhtml">IANA Character Sets registry</a>.
To stop spreading legacy encodings further, this specification is exhaustive about the
aforementioned details and therefore has no need for the registry. In particular, this
specification does not provide a mechanism for extending any aspect of encodings. </p>
   <h2 class="heading settled" data-level="2" id="security-background"><span class="secno">2. </span><span class="content">Security background</span><a class="self-link" href="#security-background"></a></h2>
   <p>There is a set of encoding security issues when the producer and consumer do not agree
on the encoding in use, or on the way a given encoding is to be implemented. For instance,
an attack was reported in 2011 where a <a data-link-type="dfn" href="#shift_jis" id="ref-for-shift_jis">Shift_JIS</a> lead byte 0x82 was used to
“mask” a 0x22 trail byte in a JSON resource of which an attacker could control some field.
The producer did not see the problem even though this is an illegal byte combination. The
consumer decoded it as a single U+FFFD and therefore changed the overall interpretation as
U+0022 is an important delimiter. Decoders of encodings that use multiple bytes for scalar
values now require that in case of an illegal byte combination, a scalar value in the
range U+0000 to U+007F, inclusive, cannot be “masked”. For the aforementioned sequence the
output would be U+FFFD U+0022. </p>
   <p>This is a larger issue for encodings that map anything that is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte">ASCII byte</a> to
something that is not an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point">ASCII code point</a>, when there is no lead byte present. These
are “ASCII-incompatible” encodings and other than <a data-link-type="dfn" href="#iso-2022-jp" id="ref-for-iso-2022-jp">ISO-2022-JP</a>, <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be">UTF-16BE</a>,
and <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le">UTF-16LE</a>, which are unfortunately required due to deployed content, they are not
supported. (Investigation is <a href="https://github.com/whatwg/encoding/issues/8">ongoing</a> whether more labels of other such encodings can be mapped to the <a data-link-type="dfn" href="#replacement" id="ref-for-replacement">replacement</a> encoding, rather than the unknown encoding fallback.) An example attack is injecting
carefully crafted content into a resource and then encouraging the user to override the
encoding, resulting in e.g. script execution. </p>
   <p>Encoders used by URLs found in HTML and HTML’s form feature can also result in slight
information loss when an encoding is used that cannot represent all scalar values. E.g.
when a resource uses the <a data-link-type="dfn" href="#windows-1252" id="ref-for-windows-1252">windows-1252</a> encoding a server will not be able to
distinguish between an end user entering “💩” and “&amp;#128169;” into a form. </p>
   <p>The problems outlined here go away when exclusively using UTF-8, which is one of the
many reasons that is now the mandatory encoding for all things. </p>
   <p class="note" role="note">See also the <a href="#browser-ui">Browser UI</a> chapter. </p>
   <h2 class="heading settled" data-level="3" id="terminology"><span class="secno">3. </span><span class="content">Terminology</span><a class="self-link" href="#terminology"></a></h2>
   <p>This specification depends on the Infra Standard. <a data-link-type="biblio" href="#biblio-infra">[INFRA]</a> </p>
   <p>Hexadecimal numbers are prefixed with "0x". </p>
   <p>In equations, all numbers are integers, addition is represented by "+", subtraction by "−",
multiplication by "×", integer division by "/" (returns the quotient), modulo by "%" (returns the
remainder of an integer division), logical left shifts by "&lt;&lt;", logical right shifts by ">>",
bitwise AND by "&amp;", and bitwise OR by "|". </p>
   <p>For logical right shifts operands must have at least twenty-one bits precision. </p>
   <hr>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="concept-token">token</dfn> is a piece of data, such as a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#byte" id="ref-for-byte">byte</a> or <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#code-point" id="ref-for-code-point">code point</a>. </p>
   <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="concept-stream">stream</dfn> represents an ordered sequence of <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token">tokens</a>. <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="end-of-stream">End-of-stream</dfn> is a special <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token①">token</a> that signifies no more <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token②">tokens</a> are in the <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream">stream</a>. </p>
   <p>When a <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token③">token</a> is <dfn class="dfn-paneled" data-dfn-for="stream" data-dfn-type="dfn" data-noexport id="concept-stream-read">read</dfn> from a <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①">stream</a>,
the first token in the stream must be returned and subsequently removed, and <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream">end-of-stream</a> must be returned otherwise. </p>
   <p>When one or more <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token④">tokens</a> are <dfn class="dfn-paneled" data-dfn-for="stream" data-dfn-type="dfn" data-noexport id="concept-stream-prepend">prepended</dfn> to a <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream②">stream</a>, those tokens must be inserted, in given order,
before the first token in the stream. </p>
   <p class="example" id="example-tokens"><a class="self-link" href="#example-tokens"></a>Inserting the sequence of tokens <code>&amp;#128169;</code> in a stream "<code> hello world</code>", results in a stream
"<code>&amp;#128169; hello world</code>". The next token to be read would be <code>&amp;</code>. </p>
   <p>When one or more <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token⑤">tokens</a> are <dfn class="dfn-paneled" data-dfn-for="stream" data-dfn-type="dfn" data-noexport id="concept-stream-push">pushed</dfn> to a <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream③">stream</a>,
those tokens must be inserted, in given order, after the last token in the stream. </p>
   <h2 class="heading settled" data-level="4" id="encodings"><span class="secno">4. </span><span class="content">Encodings</span><a class="self-link" href="#encodings"></a></h2>
   <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="encoding">encoding</dfn> defines a mapping from a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#scalar-value" id="ref-for-scalar-value">scalar value</a> sequence to
a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#byte" id="ref-for-byte①">byte</a> sequence (and vice versa). Each <a data-link-type="dfn" href="#encoding" id="ref-for-encoding">encoding</a> has a <dfn class="dfn-paneled" data-dfn-for="encoding" data-dfn-type="dfn" data-export id="name">name</dfn>, and one or more <dfn class="dfn-paneled" data-dfn-for="encoding" data-dfn-type="dfn" data-export data-lt="label" id="label">labels</dfn>. </p>
   <p class="note no-backref" role="note">This specification defines three <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①">encodings</a> with the same
names as <i>encoding schemes</i> defined in the Unicode standard: <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8">UTF-8</a>, <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le①">UTF-16LE</a>, and <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be①">UTF-16BE</a>. The <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②">encodings</a> differ from the <i>encoding schemes</i> by byte order
mark (also known as BOM) handling not being part of the <a data-link-type="dfn" href="#encoding" id="ref-for-encoding③">encodings</a> themselves and
instead being part of wrapper algorithms in this specification, whereas byte order mark handling is
part of the definition of the <i>encoding schemes</i> in the Unicode Standard. <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①">UTF-8</a> used
together with the <a data-link-type="dfn" href="#utf-8-decode" id="ref-for-utf-8-decode">UTF-8 decode</a> algorithm matches the <i>encoding scheme</i> of the same name.
This specification does not provide wrapper algorithms that would combine with <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le②">UTF-16LE</a> and <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be②">UTF-16BE</a> to match the similarly-named <i>encoding schemes</i>. <a data-link-type="biblio" href="#biblio-unicode">[UNICODE]</a> </p>
   <h3 class="heading settled" data-level="4.1" id="encoders-and-decoders"><span class="secno">4.1. </span><span class="content">Encoders and decoders</span><a class="self-link" href="#encoders-and-decoders"></a></h3>
   <p>Each <a data-link-type="dfn" href="#encoding" id="ref-for-encoding④">encoding</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="decoder">decoder</dfn> and most of them have an
associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="encoder">encoder</dfn>. Each <a data-link-type="dfn" href="#decoder" id="ref-for-decoder">decoder</a> and <a data-link-type="dfn" href="#encoder" id="ref-for-encoder">encoder</a> have a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="handler">handler</dfn> algorithm. A <a data-link-type="dfn" href="#handler" id="ref-for-handler">handler</a> algorithm takes an input <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream④">stream</a> and a <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token⑥">token</a>, and returns <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="finished">finished</dfn>, one or more <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token⑦">tokens</a>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="error">error</dfn> optionally with a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#code-point" id="ref-for-code-point①">code point</a>, or <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="continue">continue</dfn>. </p>
   <p class="note no-backref" role="note">The <a data-link-type="dfn" href="#replacement" id="ref-for-replacement①">replacement</a>, <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be③">UTF-16BE</a>, and <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le③">UTF-16LE</a> <a data-link-type="dfn" href="#encoding" id="ref-for-encoding⑤">encodings</a> have no <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①">encoder</a>. </p>
   <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="error-mode">error mode</dfn> as used below is "<code>replacement</code>" (default) or
"<code>fatal</code>" for a <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①">decoder</a> and "<code>fatal</code>" (default) or
"<code>html</code>" for an <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②">encoder</a>. </p>
   <p class="note" role="note">An XML processor would set <a data-link-type="dfn" href="#error-mode" id="ref-for-error-mode">error mode</a> to "<code>fatal</code>". <a data-link-type="biblio" href="#biblio-xml">[XML]</a> </p>
   <p class="note" role="note"><code>html</code> exists as <a data-link-type="dfn" href="#error-mode" id="ref-for-error-mode①">error mode</a> due to URLs and HTML forms
requiring a non-terminating legacy <a data-link-type="dfn" href="#encoder" id="ref-for-encoder③">encoder</a>. The "<code>html</code>" <a data-link-type="dfn" href="#error-mode" id="ref-for-error-mode②">error mode</a> causes a sequence to be emitted that cannot be distinguished from
legitimate input and can therefore lead to silent data loss. Developers are strongly
encouraged to use the <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8②">UTF-8</a> <a data-link-type="dfn" href="#encoding" id="ref-for-encoding⑥">encoding</a> to prevent this from
happening. <a data-link-type="biblio" href="#biblio-url">[URL]</a> <a data-link-type="biblio" href="#biblio-html">[HTML]</a> </p>
   <p>To <dfn class="dfn-paneled" data-dfn-for="encoding" data-dfn-type="dfn" data-noexport id="concept-encoding-run">run</dfn> an <a data-link-type="dfn" href="#encoding" id="ref-for-encoding⑦">encoding</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②">decoder</a> or <a data-link-type="dfn" href="#encoder" id="ref-for-encoder④">encoder</a> <var>encoderDecoder</var> with input <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream⑤">stream</a> <var>input</var>, output <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream⑥">stream</a> <var>output</var>, and optional <a data-link-type="dfn" href="#error-mode" id="ref-for-error-mode③">error mode</a> <var>mode</var>, run these steps: </p>
   <ol>
    <li>
     <p>If <var>mode</var> is not given, set it to "<code>replacement</code>", if <var>encoderDecoder</var> is a <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③">decoder</a>, and "<code>fatal</code>" otherwise. </p>
    <li>
     <p>Let <var>encoderDecoderInstance</var> be a new <var>encoderDecoder</var>. </p>
    <li>
     <p>While true: </p>
     <ol>
      <li>
       <p>Let <var>result</var> be the result of <a data-link-type="dfn" href="#concept-encoding-process" id="ref-for-concept-encoding-process">processing</a> the result of <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read">reading</a> from <var>input</var> for <var>encoderDecoderInstance</var>, <var>input</var>, <var>output</var>, and <var>mode</var>. </p>
      <li>
       <p>If <var>result</var> is not <a data-link-type="dfn" href="#continue" id="ref-for-continue">continue</a>, return <var>result</var>. </p>
      <li>
       <p>Otherwise, do nothing. </p>
     </ol>
   </ol>
   <p>To <dfn class="dfn-paneled" data-dfn-for="encoding" data-dfn-type="dfn" data-noexport id="concept-encoding-process">process</dfn> a <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token⑧">token</a> <var>token</var> for an <a data-link-type="dfn" href="#encoding" id="ref-for-encoding⑧">encoding</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder⑤">encoder</a> or <a data-link-type="dfn" href="#decoder" id="ref-for-decoder④">decoder</a> instance <var>encoderDecoderInstance</var>, <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream⑦">stream</a> <var>input</var>, output <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream⑧">stream</a> <var>output</var>, and optional <a data-link-type="dfn" href="#error-mode" id="ref-for-error-mode④">error mode</a> <var>mode</var>, run these steps: </p>
   <ol>
    <li>
     <p>If <var>mode</var> is not given, set it to "<code>replacement</code>", if <var>encoderDecoderInstance</var> is a <a data-link-type="dfn" href="#decoder" id="ref-for-decoder⑤">decoder</a> instance, and "<code>fatal</code>"
 otherwise. </p>
    <li>
     <p>Let <var>result</var> be the result of running <var>encoderDecoderInstance</var>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①">handler</a> on <var>input</var> and <var>token</var>. </p>
    <li>
     <p>If <var>result</var> is <a data-link-type="dfn" href="#continue" id="ref-for-continue①">continue</a> or <a data-link-type="dfn" href="#finished" id="ref-for-finished">finished</a>, return <var>result</var>. </p>
    <li>
     <p>Otherwise, if <var>result</var> is one or more <a data-link-type="dfn" href="#concept-token" id="ref-for-concept-token⑨">tokens</a>, <a data-link-type="dfn" href="#concept-stream-push" id="ref-for-concept-stream-push">push</a> <var>result</var> to <var>output</var>. </p>
    <li>
     <p>Otherwise, if <var>result</var> is <a data-link-type="dfn" href="#error" id="ref-for-error">error</a>, switch on <var>mode</var> and
  run the associated steps: </p>
     <dl class="switch">
      <dt>"<code>replacement</code>" 
      <dd><a data-link-type="dfn" href="#concept-stream-push" id="ref-for-concept-stream-push①">Push</a> U+FFFD to <var>output</var>. 
      <dt>"<code>html</code>" 
      <dd><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend">Prepend</a> U+0026, U+0023, followed by the
   shortest sequence of <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-digit" id="ref-for-ascii-digit">ASCII digits</a> representing <var>result</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#code-point" id="ref-for-code-point②">code point</a> in base ten, followed by U+003B to <var>input</var>. 
      <dt>"<code>fatal</code>" 
      <dd>Return <a data-link-type="dfn" href="#error" id="ref-for-error①">error</a>. 
     </dl>
    <li>Return <a data-link-type="dfn" href="#continue" id="ref-for-continue②">continue</a>. 
   </ol>
   <h3 class="heading settled" data-level="4.2" id="names-and-labels"><span class="secno">4.2. </span><span class="content">Names and labels</span><a class="self-link" href="#names-and-labels"></a></h3>
   <p>The table below lists all <a data-link-type="dfn" href="#encoding" id="ref-for-encoding⑨">encodings</a> and their <a data-link-type="dfn" href="#label" id="ref-for-label">labels</a> user agents must support.
User agents must not support any other <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①⓪">encodings</a> or <a data-link-type="dfn" href="#label" id="ref-for-label①">labels</a>. </p>
   <p class="note" role="note">For each encoding, <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-lowercase" id="ref-for-ascii-lowercase">ASCII-lowercasing</a> its <a data-link-type="dfn" href="#name" id="ref-for-name">name</a> yields one of its <a data-link-type="dfn" href="#label" id="ref-for-label②">labels</a>. </p>
   <p>Authors must use the <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8③">UTF-8</a> <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①①">encoding</a> and must use the <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive">ASCII case-insensitive</a> "<code>utf-8</code>" <a data-link-type="dfn" href="#label" id="ref-for-label③">label</a> to
identify it. </p>
   <p>New protocols and formats, as well as existing formats deployed in new contexts, must
use the <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8④">UTF-8</a> <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①②">encoding</a> exclusively. If these protocols and
formats need to expose the <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①③">encoding</a>’s <a data-link-type="dfn" href="#name" id="ref-for-name①">name</a> or <a data-link-type="dfn" href="#label" id="ref-for-label④">label</a>, they must expose it as "<code>utf-8</code>". </p>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="get an encoding|getting an encoding" id="concept-encoding-get">get an encoding</dfn> from a string <var>label</var>, run these steps: </p>
   <ol>
    <li>
     <p>Remove any leading and trailing <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-whitespace" id="ref-for-ascii-whitespace">ASCII whitespace</a> from <var>label</var>. </p>
    <li>
     <p>If <var>label</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-case-insensitive" id="ref-for-ascii-case-insensitive①">ASCII case-insensitive</a> match for any of the <a data-link-type="dfn" href="#label" id="ref-for-label⑤">labels</a> listed in the table
 below, return the corresponding <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①④">encoding</a>, and failure otherwise. </p>
   </ol>
   <p class="note no-backref" role="note">This is a more basic and restrictive algorithm of mapping <a data-link-type="dfn" href="#label" id="ref-for-label⑥">labels</a> to <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①⑤">encodings</a> than <a href="https://www.unicode.org/reports/tr22/tr22-8.html#Charset_Alias_Matching">section 1.4 of Unicode Technical Standard #22</a> prescribes, as that is necessary to be compatible with deployed content. </p>
   <table>
    <thead>
     <tr>
      <th><a data-link-type="dfn" href="#name" id="ref-for-name②">Name</a> 
      <th><a data-link-type="dfn" href="#label" id="ref-for-label⑦">Labels</a> 
    <tbody>
     <tr>
      <th colspan="2"><a href="#the-encoding">The Encoding</a> 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8⑤">UTF-8</a> 
      <td>"<code>unicode-1-1-utf-8</code>" 
     <tr>
      <td>"<code>utf-8</code>" 
     <tr>
      <td>"<code>utf8</code>" 
    <tbody>
     <tr>
      <th colspan="2"><a href="#legacy-single-byte-encodings">Legacy single-byte encodings</a> 
     <tr>
      <td rowspan="4"><a data-link-type="dfn" href="#ibm866" id="ref-for-ibm866">IBM866</a> 
      <td>"<code>866</code>" 
     <tr>
      <td>"<code>cp866</code>" 
     <tr>
      <td>"<code>csibm866</code>" 
     <tr>
      <td>"<code>ibm866</code>" 
     <tr>
      <td rowspan="9"><a data-link-type="dfn" href="#iso-8859-2" id="ref-for-iso-8859-2">ISO-8859-2</a> 
      <td>"<code>csisolatin2</code>" 
     <tr>
      <td>"<code>iso-8859-2</code>" 
     <tr>
      <td>"<code>iso-ir-101</code>" 
     <tr>
      <td>"<code>iso8859-2</code>" 
     <tr>
      <td>"<code>iso88592</code>" 
     <tr>
      <td>"<code>iso_8859-2</code>" 
     <tr>
      <td>"<code>iso_8859-2:1987</code>" 
     <tr>
      <td>"<code>l2</code>" 
     <tr>
      <td>"<code>latin2</code>" 
     <tr>
      <td rowspan="9"><a data-link-type="dfn" href="#iso-8859-3" id="ref-for-iso-8859-3">ISO-8859-3</a> 
      <td>"<code>csisolatin3</code>" 
     <tr>
      <td>"<code>iso-8859-3</code>" 
     <tr>
      <td>"<code>iso-ir-109</code>" 
     <tr>
      <td>"<code>iso8859-3</code>" 
     <tr>
      <td>"<code>iso88593</code>" 
     <tr>
      <td>"<code>iso_8859-3</code>" 
     <tr>
      <td>"<code>iso_8859-3:1988</code>" 
     <tr>
      <td>"<code>l3</code>" 
     <tr>
      <td>"<code>latin3</code>" 
     <tr>
      <td rowspan="9"><a data-link-type="dfn" href="#iso-8859-4" id="ref-for-iso-8859-4">ISO-8859-4</a> 
      <td>"<code>csisolatin4</code>" 
     <tr>
      <td>"<code>iso-8859-4</code>" 
     <tr>
      <td>"<code>iso-ir-110</code>" 
     <tr>
      <td>"<code>iso8859-4</code>" 
     <tr>
      <td>"<code>iso88594</code>" 
     <tr>
      <td>"<code>iso_8859-4</code>" 
     <tr>
      <td>"<code>iso_8859-4:1988</code>" 
     <tr>
      <td>"<code>l4</code>" 
     <tr>
      <td>"<code>latin4</code>" 
     <tr>
      <td rowspan="8"><a data-link-type="dfn" href="#iso-8859-5" id="ref-for-iso-8859-5">ISO-8859-5</a> 
      <td>"<code>csisolatincyrillic</code>" 
     <tr>
      <td>"<code>cyrillic</code>" 
     <tr>
      <td>"<code>iso-8859-5</code>" 
     <tr>
      <td>"<code>iso-ir-144</code>" 
     <tr>
      <td>"<code>iso8859-5</code>" 
     <tr>
      <td>"<code>iso88595</code>" 
     <tr>
      <td>"<code>iso_8859-5</code>" 
     <tr>
      <td>"<code>iso_8859-5:1988</code>" 
     <tr>
      <td rowspan="14"><a data-link-type="dfn" href="#iso-8859-6" id="ref-for-iso-8859-6">ISO-8859-6</a> 
      <td>"<code>arabic</code>" 
     <tr>
      <td>"<code>asmo-708</code>" 
     <tr>
      <td>"<code>csiso88596e</code>" 
     <tr>
      <td>"<code>csiso88596i</code>" 
     <tr>
      <td>"<code>csisolatinarabic</code>" 
     <tr>
      <td>"<code>ecma-114</code>" 
     <tr>
      <td>"<code>iso-8859-6</code>" 
     <tr>
      <td>"<code>iso-8859-6-e</code>" 
     <tr>
      <td>"<code>iso-8859-6-i</code>" 
     <tr>
      <td>"<code>iso-ir-127</code>" 
     <tr>
      <td>"<code>iso8859-6</code>" 
     <tr>
      <td>"<code>iso88596</code>" 
     <tr>
      <td>"<code>iso_8859-6</code>" 
     <tr>
      <td>"<code>iso_8859-6:1987</code>" 
     <tr>
      <td rowspan="12"><a data-link-type="dfn" href="#iso-8859-7" id="ref-for-iso-8859-7">ISO-8859-7</a> 
      <td>"<code>csisolatingreek</code>" 
     <tr>
      <td>"<code>ecma-118</code>" 
     <tr>
      <td>"<code>elot_928</code>" 
     <tr>
      <td>"<code>greek</code>" 
     <tr>
      <td>"<code>greek8</code>" 
     <tr>
      <td>"<code>iso-8859-7</code>" 
     <tr>
      <td>"<code>iso-ir-126</code>" 
     <tr>
      <td>"<code>iso8859-7</code>" 
     <tr>
      <td>"<code>iso88597</code>" 
     <tr>
      <td>"<code>iso_8859-7</code>" 
     <tr>
      <td>"<code>iso_8859-7:1987</code>" 
     <tr>
      <td>"<code>sun_eu_greek</code>" 
     <tr>
      <td rowspan="11"><a data-link-type="dfn" href="#iso-8859-8" id="ref-for-iso-8859-8">ISO-8859-8</a> 
      <td>"<code>csiso88598e</code>" 
     <tr>
      <td>"<code>csisolatinhebrew</code>" 
     <tr>
      <td>"<code>hebrew</code>" 
     <tr>
      <td>"<code>iso-8859-8</code>" 
     <tr>
      <td>"<code>iso-8859-8-e</code>" 
     <tr>
      <td>"<code>iso-ir-138</code>" 
     <tr>
      <td>"<code>iso8859-8</code>" 
     <tr>
      <td>"<code>iso88598</code>" 
     <tr>
      <td>"<code>iso_8859-8</code>" 
     <tr>
      <td>"<code>iso_8859-8:1988</code>" 
     <tr>
      <td>"<code>visual</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#iso-8859-8-i" id="ref-for-iso-8859-8-i">ISO-8859-8-I</a> 
      <td>"<code>csiso88598i</code>" 
     <tr>
      <td>"<code>iso-8859-8-i</code>" 
     <tr>
      <td>"<code>logical</code>" 
     <tr>
      <td rowspan="7"><a data-link-type="dfn" href="#iso-8859-10" id="ref-for-iso-8859-10">ISO-8859-10</a> 
      <td>"<code>csisolatin6</code>" 
     <tr>
      <td>"<code>iso-8859-10</code>" 
     <tr>
      <td>"<code>iso-ir-157</code>" 
     <tr>
      <td>"<code>iso8859-10</code>" 
     <tr>
      <td>"<code>iso885910</code>" 
     <tr>
      <td>"<code>l6</code>" 
     <tr>
      <td>"<code>latin6</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#iso-8859-13" id="ref-for-iso-8859-13">ISO-8859-13</a> 
      <td>"<code>iso-8859-13</code>" 
     <tr>
      <td>"<code>iso8859-13</code>" 
     <tr>
      <td>"<code>iso885913</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#iso-8859-14" id="ref-for-iso-8859-14">ISO-8859-14</a> 
      <td>"<code>iso-8859-14</code>" 
     <tr>
      <td>"<code>iso8859-14</code>" 
     <tr>
      <td>"<code>iso885914</code>" 
     <tr>
      <td rowspan="6"><a data-link-type="dfn" href="#iso-8859-15" id="ref-for-iso-8859-15">ISO-8859-15</a> 
      <td>"<code>csisolatin9</code>" 
     <tr>
      <td>"<code>iso-8859-15</code>" 
     <tr>
      <td>"<code>iso8859-15</code>" 
     <tr>
      <td>"<code>iso885915</code>" 
     <tr>
      <td>"<code>iso_8859-15</code>" 
     <tr>
      <td>"<code>l9</code>" 
     <tr>
      <td><a data-link-type="dfn" href="#iso-8859-16" id="ref-for-iso-8859-16">ISO-8859-16</a> 
      <td>"<code>iso-8859-16</code>" 
     <tr>
      <td rowspan="5"><a data-link-type="dfn" href="#koi8-r" id="ref-for-koi8-r">KOI8-R</a> 
      <td>"<code>cskoi8r</code>" 
     <tr>
      <td>"<code>koi</code>" 
     <tr>
      <td>"<code>koi8</code>" 
     <tr>
      <td>"<code>koi8-r</code>" 
     <tr>
      <td>"<code>koi8_r</code>" 
     <tr>
      <td rowspan="2"><a data-link-type="dfn" href="#koi8-u" id="ref-for-koi8-u">KOI8-U</a> 
      <td>"<code>koi8-ru</code>" 
     <tr>
      <td>"<code>koi8-u</code>" 
     <tr>
      <td rowspan="4"><a data-link-type="dfn" href="#macintosh" id="ref-for-macintosh">macintosh</a> 
      <td>"<code>csmacintosh</code>" 
     <tr>
      <td>"<code>mac</code>" 
     <tr>
      <td>"<code>macintosh</code>" 
     <tr>
      <td>"<code>x-mac-roman</code>" 
     <tr>
      <td rowspan="6"><a data-link-type="dfn" href="#windows-874" id="ref-for-windows-874">windows-874</a> 
      <td>"<code>dos-874</code>" 
     <tr>
      <td>"<code>iso-8859-11</code>" 
     <tr>
      <td>"<code>iso8859-11</code>" 
     <tr>
      <td>"<code>iso885911</code>" 
     <tr>
      <td>"<code>tis-620</code>" 
     <tr>
      <td>"<code>windows-874</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#windows-1250" id="ref-for-windows-1250">windows-1250</a> 
      <td>"<code>cp1250</code>" 
     <tr>
      <td>"<code>windows-1250</code>" 
     <tr>
      <td>"<code>x-cp1250</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#windows-1251" id="ref-for-windows-1251">windows-1251</a> 
      <td>"<code>cp1251</code>" 
     <tr>
      <td>"<code>windows-1251</code>" 
     <tr>
      <td>"<code>x-cp1251</code>" 
     <tr>
      <td rowspan="17"><a data-link-type="dfn" href="#windows-1252" id="ref-for-windows-1252①">windows-1252</a> 
      <td>"<code>ansi_x3.4-1968</code>" 
     <tr>
      <td>"<code>ascii</code>" 
     <tr>
      <td>"<code>cp1252</code>" 
     <tr>
      <td>"<code>cp819</code>" 
     <tr>
      <td>"<code>csisolatin1</code>" 
     <tr>
      <td>"<code>ibm819</code>" 
     <tr>
      <td>"<code>iso-8859-1</code>" 
     <tr>
      <td>"<code>iso-ir-100</code>" 
     <tr>
      <td>"<code>iso8859-1</code>" 
     <tr>
      <td>"<code>iso88591</code>" 
     <tr>
      <td>"<code>iso_8859-1</code>" 
     <tr>
      <td>"<code>iso_8859-1:1987</code>" 
     <tr>
      <td>"<code>l1</code>" 
     <tr>
      <td>"<code>latin1</code>" 
     <tr>
      <td>"<code>us-ascii</code>" 
     <tr>
      <td>"<code>windows-1252</code>" 
     <tr>
      <td>"<code>x-cp1252</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#windows-1253" id="ref-for-windows-1253">windows-1253</a> 
      <td>"<code>cp1253</code>" 
     <tr>
      <td>"<code>windows-1253</code>" 
     <tr>
      <td>"<code>x-cp1253</code>" 
     <tr>
      <td rowspan="12"><a data-link-type="dfn" href="#windows-1254" id="ref-for-windows-1254">windows-1254</a> 
      <td>"<code>cp1254</code>" 
     <tr>
      <td>"<code>csisolatin5</code>" 
     <tr>
      <td>"<code>iso-8859-9</code>" 
     <tr>
      <td>"<code>iso-ir-148</code>" 
     <tr>
      <td>"<code>iso8859-9</code>" 
     <tr>
      <td>"<code>iso88599</code>" 
     <tr>
      <td>"<code>iso_8859-9</code>" 
     <tr>
      <td>"<code>iso_8859-9:1989</code>" 
     <tr>
      <td>"<code>l5</code>" 
     <tr>
      <td>"<code>latin5</code>" 
     <tr>
      <td>"<code>windows-1254</code>" 
     <tr>
      <td>"<code>x-cp1254</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#windows-1255" id="ref-for-windows-1255">windows-1255</a> 
      <td>"<code>cp1255</code>" 
     <tr>
      <td>"<code>windows-1255</code>" 
     <tr>
      <td>"<code>x-cp1255</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#windows-1256" id="ref-for-windows-1256">windows-1256</a> 
      <td>"<code>cp1256</code>" 
     <tr>
      <td>"<code>windows-1256</code>" 
     <tr>
      <td>"<code>x-cp1256</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#windows-1257" id="ref-for-windows-1257">windows-1257</a> 
      <td>"<code>cp1257</code>" 
     <tr>
      <td>"<code>windows-1257</code>" 
     <tr>
      <td>"<code>x-cp1257</code>" 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#windows-1258" id="ref-for-windows-1258">windows-1258</a> 
      <td>"<code>cp1258</code>" 
     <tr>
      <td>"<code>windows-1258</code>" 
     <tr>
      <td>"<code>x-cp1258</code>" 
     <tr>
      <td rowspan="2"><a data-link-type="dfn" href="#x-mac-cyrillic" id="ref-for-x-mac-cyrillic">x-mac-cyrillic</a> 
      <td>"<code>x-mac-cyrillic</code>" 
     <tr>
      <td>"<code>x-mac-ukrainian</code>" 
    <tbody>
     <tr>
      <th colspan="2"><a href="#legacy-multi-byte-chinese-(simplified)-encodings">Legacy multi-byte Chinese (simplified) encodings</a> 
     <tr>
      <td rowspan="9"><a data-link-type="dfn" href="#gbk" id="ref-for-gbk">GBK</a> 
      <td>"<code>chinese</code>" 
     <tr>
      <td>"<code>csgb2312</code>" 
     <tr>
      <td>"<code>csiso58gb231280</code>" 
     <tr>
      <td>"<code>gb2312</code>" 
     <tr>
      <td>"<code>gb_2312</code>" 
     <tr>
      <td>"<code>gb_2312-80</code>" 
     <tr>
      <td>"<code>gbk</code>" 
     <tr>
      <td>"<code>iso-ir-58</code>" 
     <tr>
      <td>"<code>x-gbk</code>" 
     <tr>
      <td><a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030">gb18030</a> 
      <td>"<code>gb18030</code>" 
    <tbody>
     <tr>
      <th colspan="2"><a href="#legacy-multi-byte-chinese-(traditional)-encodings">Legacy multi-byte Chinese (traditional) encodings</a> 
     <tr>
      <td rowspan="5"><a data-link-type="dfn" href="#big5" id="ref-for-big5">Big5</a> 
      <td>"<code>big5</code>" 
     <tr>
      <td>"<code>big5-hkscs</code>" 
     <tr>
      <td>"<code>cn-big5</code>" 
     <tr>
      <td>"<code>csbig5</code>" 
     <tr>
      <td>"<code>x-x-big5</code>" 
    <tbody>
     <tr>
      <th colspan="2"><a href="#legacy-multi-byte-japanese-encodings">Legacy multi-byte Japanese encodings</a> 
     <tr>
      <td rowspan="3"><a data-link-type="dfn" href="#euc-jp" id="ref-for-euc-jp">EUC-JP</a> 
      <td>"<code>cseucpkdfmtjapanese</code>" 
     <tr>
      <td>"<code>euc-jp</code>" 
     <tr>
      <td>"<code>x-euc-jp</code>" 
     <tr>
      <td rowspan="2"><a data-link-type="dfn" href="#iso-2022-jp" id="ref-for-iso-2022-jp①">ISO-2022-JP</a> 
      <td>"<code>csiso2022jp</code>" 
     <tr>
      <td>"<code>iso-2022-jp</code>" 
     <tr>
      <td rowspan="8"><a data-link-type="dfn" href="#shift_jis" id="ref-for-shift_jis①">Shift_JIS</a> 
      <td>"<code>csshiftjis</code>" 
     <tr>
      <td>"<code>ms932</code>" 
     <tr>
      <td>"<code>ms_kanji</code>" 
     <tr>
      <td>"<code>shift-jis</code>" 
     <tr>
      <td>"<code>shift_jis</code>" 
     <tr>
      <td>"<code>sjis</code>" 
     <tr>
      <td>"<code>windows-31j</code>" 
     <tr>
      <td>"<code>x-sjis</code>" 
    <tbody>
     <tr>
      <th colspan="2"><a href="#legacy-multi-byte-korean-encodings">Legacy multi-byte Korean encodings</a> 
     <tr>
      <td rowspan="10"><a data-link-type="dfn" href="#euc-kr" id="ref-for-euc-kr">EUC-KR</a> 
      <td>"<code>cseuckr</code>" 
     <tr>
      <td>"<code>csksc56011987</code>" 
     <tr>
      <td>"<code>euc-kr</code>" 
     <tr>
      <td>"<code>iso-ir-149</code>" 
     <tr>
      <td>"<code>korean</code>" 
     <tr>
      <td>"<code>ks_c_5601-1987</code>" 
     <tr>
      <td>"<code>ks_c_5601-1989</code>" 
     <tr>
      <td>"<code>ksc5601</code>" 
     <tr>
      <td>"<code>ksc_5601</code>" 
     <tr>
      <td>"<code>windows-949</code>" 
    <tbody>
     <tr>
      <th colspan="2"><a href="#legacy-miscellaneous-encodings">Legacy miscellaneous encodings</a> 
     <tr>
      <td rowspan="6"><a data-link-type="dfn" href="#replacement" id="ref-for-replacement②">replacement</a> 
      <td>"<code>csiso2022kr</code>" 
     <tr>
      <td>"<code>hz-gb-2312</code>" 
     <tr>
      <td>"<code>iso-2022-cn</code>" 
     <tr>
      <td>"<code>iso-2022-cn-ext</code>" 
     <tr>
      <td>"<code>iso-2022-kr</code>" 
     <tr>
      <td>"<code>replacement</code>" 
     <tr>
      <td><a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be④">UTF-16BE</a> 
      <td>"<code>utf-16be</code>" 
     <tr>
      <td rowspan="2"><a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le④">UTF-16LE</a> 
      <td>"<code>utf-16</code>" 
     <tr>
      <td>"<code>utf-16le</code>" 
     <tr>
      <td><a data-link-type="dfn" href="#x-user-defined" id="ref-for-x-user-defined">x-user-defined</a> 
      <td>"<code>x-user-defined</code>" 
   </table>
   <p class="note" role="note">All <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①⑥">encodings</a> and their <a data-link-type="dfn" href="#label" id="ref-for-label⑧">labels</a> are also available as non-normative <a href="encodings.json">encodings.json</a> resource. </p>
   <h3 class="heading settled" data-level="4.3" id="output-encodings"><span class="secno">4.3. </span><span class="content">Output encodings</span><a class="self-link" href="#output-encodings"></a></h3>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="get-an-output-encoding">get an output encoding</dfn> from an <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①⑦">encoding</a> <var>encoding</var>, run these steps: </p>
   <ol>
    <li>
     <p>If <var>encoding</var> is <a data-link-type="dfn" href="#replacement" id="ref-for-replacement③">replacement</a>, <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be⑤">UTF-16BE</a>, or <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le⑤">UTF-16LE</a>, return <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8⑥">UTF-8</a>. </p>
    <li>
     <p>Return <var>encoding</var>. </p>
   </ol>
   <p class="note" role="note">The <a data-link-type="dfn" href="#get-an-output-encoding" id="ref-for-get-an-output-encoding">get an output encoding</a> algorithm is useful for URL parsing and HTML
form submission, which both need exactly this. </p>
   <h2 class="heading settled" data-level="5" id="indexes"><span class="secno">5. </span><span class="content">Indexes</span><a class="self-link" href="#indexes"></a></h2>
   <p>Most legacy <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①⑧">encodings</a> make use of an <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index">index</dfn>. An <a data-link-type="dfn" href="#index" id="ref-for-index">index</a> is an ordered list of entries, each entry consisting of a pointer and a
corresponding code point. Within an <a data-link-type="dfn" href="#index" id="ref-for-index①">index</a> pointers are unique and code points can be
duplicated. </p>
   <p class="note no-backref" role="note">An efficient implementation likely has two <a data-link-type="dfn" href="#index" id="ref-for-index②">indexes</a> per <a data-link-type="dfn" href="#encoding" id="ref-for-encoding①⑨">encoding</a>. One optimized for its <a data-link-type="dfn" href="#decoder" id="ref-for-decoder⑥">decoder</a> and one for its <a data-link-type="dfn" href="#encoder" id="ref-for-encoder⑥">encoder</a>. </p>
   <p>To find the pointers and their corresponding code points in an <a data-link-type="dfn" href="#index" id="ref-for-index③">index</a>,
let <var>lines</var> be the result of splitting the resource’s contents on U+000A.
Then remove each item in <var>lines</var> that is the empty string or starts with U+0023.
Then the pointers and their corresponding code points are found by splitting each item in <var>lines</var> on U+0009.
The first subitem is the pointer (as a decimal number) and the second is the corresponding code point (as a hexadecimal number).
Other subitems are not relevant. </p>
   <p class="note no-backref" role="note">To signify changes an <a data-link-type="dfn" href="#index" id="ref-for-index④">index</a> includes an <i>Identifier</i> and a <i>Date</i>. If an <i>Identifier</i> has
changed, so has the <a data-link-type="dfn" href="#index" id="ref-for-index⑤">index</a>. </p>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index-code-point">index code point</dfn> for <var>pointer</var> in <var>index</var> is the code point corresponding to <var>pointer</var> in <var>index</var>, or null if <var>pointer</var> is not in <var>index</var>. </p>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index-pointer">index pointer</dfn> for <var>code point</var> in <var>index</var> is the <em>first</em> pointer corresponding to <var>code point</var> in <var>index</var>, or null if <var>code point</var> is not in <var>index</var>. </p>
   <div class="note" id="visualization" role="note">
    <a class="self-link" href="#visualization"></a> 
    <p>There is a non-normative visualization for each <a data-link-type="dfn" href="#index" id="ref-for-index⑥">index</a> other than <a data-link-type="dfn" href="#index-gb18030-ranges" id="ref-for-index-gb18030-ranges">index gb18030 ranges</a> and <a data-link-type="dfn" href="#index-iso-2022-jp-katakana" id="ref-for-index-iso-2022-jp-katakana">index ISO-2022-JP katakana</a>. <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208">index jis0208</a> also has an
 alternative <a data-link-type="dfn" href="#shift_jis" id="ref-for-shift_jis②">Shift_JIS</a> visualization. Additionally, there is visualization of the Basic
 Multilingual Plane coverage of each index other than <a data-link-type="dfn" href="#index-gb18030-ranges" id="ref-for-index-gb18030-ranges①">index gb18030 ranges</a> and <a data-link-type="dfn" href="#index-iso-2022-jp-katakana" id="ref-for-index-iso-2022-jp-katakana①">index ISO-2022-JP katakana</a>. </p>
    <p>The legend for the visualizations is: </p>
    <ul class="visualizationlegend">
     <li class="unmapped">Unmapped 
     <li class="mid">Two bytes in UTF-8 
     <li class="mid contiguous">Two bytes in UTF-8, code point follows immediately the code point of
  previous pointer 
     <li class="upper">Three bytes in UTF-8 (non-PUA) 
     <li class="upper contiguous">Three bytes in UTF-8 (non-PUA), code point follows immediately the
  code point of previous pointer 
     <li class="pua">Private Use 
     <li class="pua contiguous">Private Use, code point follows immediately the code point of previous
  pointer 
     <li class="astral">Four bytes in UTF-8 
     <li class="astral contiguous">Four bytes in UTF-8, code point follows immediately the code point
  of previous pointer 
     <li class="duplicate">Duplicate code point already mapped at an earlier index 
     <li class="compatibility">CJK Compatibility Ideograph 
     <li class="ext">CJK Unified Ideographs Extension A 
    </ul>
   </div>
   <p>These are the <a data-link-type="dfn" href="#index" id="ref-for-index⑦">indexes</a> defined by this
specification, excluding <a data-link-type="dfn" href="#index-single-byte" id="ref-for-index-single-byte">index single-byte</a>, which have their own table: </p>
   <table>
    <tbody>
     <tr>
      <th colspan="4"><a data-link-type="dfn" href="#index" id="ref-for-index⑧">Index</a>
      <th>Notes 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="index-big5">index Big5</dfn> 
      <td><a href="index-big5.txt">index-big5.txt</a> 
      <td><a href="big5.html">index Big5 visualization</a> 
      <td><a href="big5-bmp.html">index Big5 BMP coverage</a> 
      <td>This matches the Big5 standard in combination with the
  Hong Kong Supplementary Character Set and other common extensions. 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="index-euc-kr">index EUC-KR</dfn> 
      <td><a href="index-euc-kr.txt">index-euc-kr.txt</a> 
      <td><a href="euc-kr.html">index EUC-KR visualization</a> 
      <td><a href="euc-kr-bmp.html">index EUC-KR BMP coverage</a> 
      <td>This matches the KS X 1001 standard and the Unified Hangul Code, more commonly known together
  as Windows Codepage 949. It covers the Hangul Syllables block of Unicode in its entirety. The
  Hangul block whose top left corner in the visualization is at pointer 9026 is in the Unicode
  order. Taken separately, the rest of the Hangul syllables in this index are in the Unicode order,
  too. 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="index-gb18030">index gb18030</dfn> 
      <td><a href="index-gb18030.txt">index-gb18030.txt</a> 
      <td><a href="gb18030.html">index gb18030 visualization</a> 
      <td><a href="gb18030-bmp.html">index gb18030 BMP coverage</a> 
      <td>This matches the GB18030-2005 standard for code points encoded as two bytes, except for
  0xA3 0xA0 which maps to U+3000 to be compatible with deployed content. This index covers the
  CJK Unified Ideographs block of Unicode in its entirety. Entries from that block that are above or
  to the left of (the first) U+3000 in the visualization are in the Unicode order. 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="index-gb18030-ranges">index gb18030 ranges</dfn> 
      <td colspan="3"><a href="index-gb18030-ranges.txt">index-gb18030-ranges.txt</a> 
      <td>This <a data-link-type="dfn" href="#index" id="ref-for-index⑨">index</a> works different from all others. Listing all code points would result
  in over a million items whereas they can be represented neatly in 207 ranges combined with trivial
  limit checks. It therefore only superficially matches the GB18030-2005 standard for code points
  encoded as four bytes. See also <a data-link-type="dfn" href="#index-gb18030-ranges-code-point" id="ref-for-index-gb18030-ranges-code-point">index gb18030 ranges code point</a> and <a data-link-type="dfn" href="#index-gb18030-ranges-pointer" id="ref-for-index-gb18030-ranges-pointer">index gb18030 ranges pointer</a> below. 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="index-jis0208">index jis0208</dfn> 
      <td><a href="index-jis0208.txt">index-jis0208.txt</a> 
      <td><a href="jis0208.html">index jis0208 visualization</a>, <a href="shift_jis.html">Shift_JIS visualization</a> 
      <td><a href="jis0208-bmp.html">index jis0208 BMP coverage</a> 
      <td>This is the JIS X 0208 standard including formerly proprietary
  extensions from IBM and NEC. 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="index-jis0212">index jis0212</dfn> 
      <td><a href="index-jis0212.txt">index-jis0212.txt</a> 
      <td><a href="jis0212.html">index jis0212 visualization</a> 
      <td><a href="jis0212-bmp.html">index jis0212 BMP coverage</a> 
      <td>This is the JIS X 0212 standard. It is only used by the <a data-link-type="dfn" href="#euc-jp-decoder" id="ref-for-euc-jp-decoder">EUC-JP decoder</a> due to lack of widespread support elsewhere. 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="index-iso-2022-jp-katakana">index ISO-2022-JP katakana</dfn> 
      <td colspan="3"><a href="index-iso-2022-jp-katakana.txt">index-iso-2022-jp-katakana.txt</a> 
      <td>This maps halfwidth to fullwidth katakana as per Unicode Normalization Form KC, except that
  U+FF9E and U+FF9F map to U+309B and U+309C rather than U+3099 and U+309A. It is only used by the <a data-link-type="dfn" href="#iso-2022-jp-encoder" id="ref-for-iso-2022-jp-encoder">ISO-2022-JP encoder</a>. <a data-link-type="biblio" href="#biblio-unicode">[UNICODE]</a> 
   </table>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index-gb18030-ranges-code-point">index gb18030 ranges code point</dfn> for <var>pointer</var> is
the return value of these steps: </p>
   <ol>
    <li>
     <p>If <var>pointer</var> is greater than 39419 and less than
 189000, or <var>pointer</var> is greater than 1237575, return null. </p>
    <li>
     <p>If <var>pointer</var> is 7457, return code point U+E7C7. </p>
    <li>
     <p>Let <var>offset</var> be the last pointer in <a data-link-type="dfn" href="#index-gb18030-ranges" id="ref-for-index-gb18030-ranges②">index gb18030 ranges</a> that is less than
 or equal to <var>pointer</var> and let <var>code point offset</var> be its corresponding code
 point. </p>
    <li>
     <p>Return a code point whose value is <var>code point offset</var> + <var>pointer</var> − <var>offset</var>. </p>
   </ol>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index-gb18030-ranges-pointer">index gb18030 ranges pointer</dfn> for <var>code point</var> is
the return value of these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is U+E7C7, return pointer 7457. </p>
    <li>
     <p>Let <var>offset</var> be the last code point in <a data-link-type="dfn" href="#index-gb18030-ranges" id="ref-for-index-gb18030-ranges③">index gb18030 ranges</a> that is less
 than or equal to <var>code point</var> and let <var>pointer offset</var> be its corresponding
 pointer. </p>
    <li>
     <p>Return a pointer whose value is <var>pointer offset</var> + <var>code point</var> − <var>offset</var>. </p>
   </ol>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index-shift_jis-pointer">index Shift_JIS pointer</dfn> for <var>code point</var> is the return value of these
steps: </p>
   <ol>
    <li>
     <p>Let <var>index</var> be <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208①">index jis0208</a> excluding all entries whose pointer is in
  the range 8272 to 8835, inclusive. </p>
     <p class="note" role="note">The <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208②">index jis0208</a> contains duplicate code points so the exclusion of
  these entries causes later code points to be used. </p>
    <li>
     <p>Return the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer">index pointer</a> for <var>code point</var> in <var>index</var>. </p>
   </ol>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index-big5-pointer">index Big5 pointer</dfn> for <var>code point</var> is the return value of
these steps: </p>
   <ol>
    <li>
     <p>Let <var>index</var> be <a data-link-type="dfn" href="#index-big5" id="ref-for-index-big5">index Big5</a> excluding all entries whose pointer is less
  than (0xA1 - 0x81) × 157. </p>
     <p class="note" role="note">Avoid returning Hong Kong Supplementary Character Set extensions literally. </p>
    <li>
     <p>If <var>code point</var> is U+2550, U+255E, U+2561, U+256A, U+5341, or U+5345,
  return the <em>last</em> pointer corresponding to <var>code point</var> in <var>index</var>. </p>
     <p class="note" role="note">There are other duplicate code points, but for those the <em>first</em> pointer is
  to be used. </p>
    <li>
     <p>Return the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer①">index pointer</a> for <var>code point</var> in <var>index</var>. </p>
   </ol>
   <hr>
   <p class="note no-backref" role="note">All <a data-link-type="dfn" href="#index" id="ref-for-index①⓪">indexes</a> are also available as a non-normative <a href="indexes.json">indexes.json</a> resource. (<a data-link-type="dfn" href="#index-gb18030-ranges" id="ref-for-index-gb18030-ranges④">Index gb18030 ranges</a> has a slightly
different format here, to be able to represent ranges.) </p>
   <h2 class="heading settled" data-level="6" id="specification-hooks"><span class="secno">6. </span><span class="content">Hooks for standards</span><a class="self-link" href="#specification-hooks"></a></h2>
   <div class="note" role="note">
    <p>The algorithms defined below (<a data-link-type="dfn" href="#decode" id="ref-for-decode">decode</a>, <a data-link-type="dfn" href="#utf-8-decode" id="ref-for-utf-8-decode①">UTF-8 decode</a>, <a data-link-type="dfn" href="#utf-8-decode-without-bom" id="ref-for-utf-8-decode-without-bom">UTF-8 decode without BOM</a>, <a data-link-type="dfn" href="#utf-8-decode-without-bom-or-fail" id="ref-for-utf-8-decode-without-bom-or-fail">UTF-8 decode without BOM or fail</a>, <a data-link-type="dfn" href="#encode" id="ref-for-encode">encode</a>, and <a data-link-type="dfn" href="#utf-8-encode" id="ref-for-utf-8-encode">UTF-8 encode</a>) are intended for usage by other standards. </p>
    <p>For decoding, <a data-link-type="dfn" href="#utf-8-decode" id="ref-for-utf-8-decode②">UTF-8 decode</a> is to be used by new formats. For identifiers or byte
 sequences within a format or protocol, use <a data-link-type="dfn" href="#utf-8-decode-without-bom" id="ref-for-utf-8-decode-without-bom①">UTF-8 decode without BOM</a> or <a data-link-type="dfn" href="#utf-8-decode-without-bom-or-fail" id="ref-for-utf-8-decode-without-bom-or-fail①">UTF-8 decode without BOM or fail</a>. </p>
    <p>For encoding, <a data-link-type="dfn" href="#utf-8-encode" id="ref-for-utf-8-encode①">UTF-8 encode</a> is to be used. </p>
    <p>Standards are strongly discouraged from using <a data-link-type="dfn" href="#decode" id="ref-for-decode①">decode</a> and <a data-link-type="dfn" href="#encode" id="ref-for-encode①">encode</a>, except as
 needed for compatibility. </p>
    <p>The <a data-link-type="dfn" href="#concept-encoding-get" id="ref-for-concept-encoding-get">get an encoding</a> algorithm is to be used to turn a <a data-link-type="dfn" href="#label" id="ref-for-label⑨">label</a> into an <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②⓪">encoding</a>. </p>
   </div>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="decode">decode</dfn> a byte stream <var>stream</var> using
fallback encoding <var>encoding</var>, run these steps: </p>
   <ol>
    <li>
     <p>Let <var>buffer</var> be an empty byte sequence. </p>
    <li>
     <p>Let <var>BOM seen flag</var> be unset. </p>
    <li>
     <p><a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read①">Read</a> bytes from <var>stream</var> into <var>buffer</var> until either <var>buffer</var> contains three bytes or <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read②">read</a> returns <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①">end-of-stream</a>. </p>
    <li>
     <p>For each of the rows in the table below, starting with the first
  one and going down, if the first bytes of <var>buffer</var> match
  all the bytes given in the first column, then set <var>encoding</var> to the <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②①">encoding</a> given in the cell in the second column of
  that row and set <var>BOM seen flag</var>. </p>
     <table>
      <tbody>
       <tr>
        <th>Byte order mark
        <th>Encoding 
       <tr>
        <td>0xEF 0xBB 0xBF
        <td><a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8⑦">UTF-8</a> 
       <tr>
        <td>0xFE 0xFF
        <td><a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be⑥">UTF-16BE</a> 
       <tr>
        <td>0xFF 0xFE
        <td><a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le⑥">UTF-16LE</a> 
     </table>
     <p class="note" role="note">For compatibility with deployed content, the byte order mark is more authoritative
  than anything else. In a context where HTTP is used this is in violation of the semantics of the
  `<code>Content-Type</code>` header. </p>
    <li>
     <p>If <var>BOM seen flag</var> is unset, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①">prepend</a> <var>buffer</var> to <var>stream</var>. </p>
    <li>
     <p>Otherwise, if <var>BOM seen flag</var> is set, <var>encoding</var> is not <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8⑧">UTF-8</a>, and <var>buffer</var> contains three bytes, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend②">prepend</a> the last byte of <var>buffer</var> to <var>stream</var>. </p>
    <li>
     <p>Let <var>output</var> be a code point <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream⑨">stream</a>. </p>
    <li>
     <p><a data-link-type="dfn" href="#concept-encoding-run" id="ref-for-concept-encoding-run">Run</a> <var>encoding</var>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder⑦">decoder</a> with <var>stream</var> and <var>output</var>. </p>
    <li>
     <p>Return <var>output</var>. </p>
   </ol>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="utf-8-decode">UTF-8 decode</dfn> a byte stream <var>stream</var>, run
these steps: </p>
   <ol>
    <li>
     <p>Let <var>buffer</var> be an empty byte sequence. </p>
    <li>
     <p><a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read③">Read</a> three bytes from <var>stream</var> into <var>buffer</var>. </p>
    <li>
     <p>If <var>buffer</var> does not match 0xEF 0xBB 0xBF, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend③">prepend</a> <var>buffer</var> to <var>stream</var>. </p>
    <li>
     <p>Let <var>output</var> be a code point <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①⓪">stream</a>. </p>
    <li>
     <p><a data-link-type="dfn" href="#concept-encoding-run" id="ref-for-concept-encoding-run①">Run</a> <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8⑨">UTF-8</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder⑧">decoder</a> with <var>stream</var> and <var>output</var>. </p>
    <li>
     <p>Return <var>output</var>. </p>
   </ol>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="utf-8-decode-without-bom">UTF-8 decode without BOM</dfn> a byte stream <var>stream</var>, run these
steps: </p>
   <ol>
    <li>
     <p>Let <var>output</var> be a code point <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①①">stream</a>. </p>
    <li>
     <p><a data-link-type="dfn" href="#concept-encoding-run" id="ref-for-concept-encoding-run②">Run</a> <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①⓪">UTF-8</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder⑨">decoder</a> with <var>stream</var> and <var>output</var>. </p>
    <li>
     <p>Return <var>output</var>. </p>
   </ol>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="utf-8-decode-without-bom-or-fail">UTF-8 decode without BOM or fail</dfn> a byte stream <var>stream</var>, run these
steps: </p>
   <ol>
    <li>
     <p>Let <var>output</var> be a code point stream. </p>
    <li>
     <p>Let <var>potentialError</var> be the result of <a data-link-type="dfn" href="#concept-encoding-run" id="ref-for-concept-encoding-run③">running</a> <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①①">UTF-8</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①⓪">decoder</a> with <var>stream</var>, <var>output</var>, and
 "<code>fatal</code>". </p>
    <li>
     <p>If <var>potentialError</var> is <a data-link-type="dfn" href="#error" id="ref-for-error②">error</a>, return failure. </p>
    <li>
     <p>Return <var>output</var>. </p>
   </ol>
   <hr>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="encode">encode</dfn> a code point stream <var>stream</var> using
encoding <var>encoding</var>, run these steps: </p>
   <ol>
    <li>
     <p>Assert: <var>encoding</var> is not <a data-link-type="dfn" href="#replacement" id="ref-for-replacement④">replacement</a>, <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be⑦">UTF-16BE</a> or <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le⑦">UTF-16LE</a>. </p>
    <li>
     <p>Let <var>output</var> be a byte <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①②">stream</a>. </p>
    <li>
     <p><a data-link-type="dfn" href="#concept-encoding-run" id="ref-for-concept-encoding-run④">Run</a> <var>encoding</var>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder⑦">encoder</a> with <var>stream</var>, <var>output</var>, and "<code>html</code>". </p>
    <li>
     <p>Return <var>output</var>. </p>
   </ol>
   <p class="note no-backref" role="note">This is mostly a legacy hook for URLs and HTML forms. Layering <a data-link-type="dfn" href="#utf-8-encode" id="ref-for-utf-8-encode②">UTF-8 encode</a> on top is safe as it never triggers <a data-link-type="dfn" href="#error" id="ref-for-error③">errors</a>. <a data-link-type="biblio" href="#biblio-url">[URL]</a> <a data-link-type="biblio" href="#biblio-html">[HTML]</a> </p>
   <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="utf-8-encode">UTF-8 encode</dfn> a code point stream <var>stream</var>,
return the result of <a data-link-type="dfn" href="#encode" id="ref-for-encode②">encoding</a> <var>stream</var> using encoding <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①②">UTF-8</a>. </p>
   <h2 class="heading settled" data-level="7" id="api"><span class="secno">7. </span><span class="content">API</span><a class="self-link" href="#api"></a></h2>
   <p>This section uses terminology from Web IDL. Browser user agents must support this API. JavaScript
implementations should support this API. Other user agents or programming languages are encouraged
to use an API suitable to their needs, which might not be this one. <a data-link-type="biblio" href="#biblio-webidl">[WEBIDL]</a> </p>
   <div class="example" id="example-textencoder">
    <a class="self-link" href="#example-textencoder"></a> 
    <p>The following example uses the <code class="idl"><a data-link-type="idl" href="#textencoder" id="ref-for-textencoder">TextEncoder</a></code> object to encode
 an array of strings into an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-ArrayBuffer" id="ref-for-idl-ArrayBuffer">ArrayBuffer</a></code>. The result is a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array">Uint8Array</a></code> containing the number
 of strings (as a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint32Array" id="ref-for-idl-Uint32Array">Uint32Array</a></code>),
 followed by the length of the first string (as a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint32Array" id="ref-for-idl-Uint32Array①">Uint32Array</a></code>), the <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①③">UTF-8</a> encoded string data, the length of the second string (as
 a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint32Array" id="ref-for-idl-Uint32Array②">Uint32Array</a></code>), the string data,
 and so on. </p>
<pre><code class="lang-javascript highlight"><c- a>function</c-> encodeArrayOfStrings<c- p>(</c->strings<c- p>)</c-> <c- p>{</c->
  <c- a>var</c-> encoder<c- p>,</c-> encoded<c- p>,</c-> len<c- p>,</c-> bytes<c- p>,</c-> view<c- p>,</c-> offset<c- p>;</c->

  encoder <c- o>=</c-> <c- k>new</c-> TextEncoder<c- p>();</c->
  encoded <c- o>=</c-> <c- p>[];</c->

  len <c- o>=</c-> Uint32Array<c- p>.</c->BYTES_PER_ELEMENT<c- p>;</c->
  <c- k>for</c-> <c- p>(</c-><c- a>var</c-> i <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> i <c- o>&lt;</c-> strings<c- p>.</c->length<c- p>;</c-> i<c- o>++</c-><c- p>)</c-> <c- p>{</c->
    len <c- o>+=</c-> Uint32Array<c- p>.</c->BYTES_PER_ELEMENT<c- p>;</c->
    encoded<c- p>[</c->i<c- p>]</c-> <c- o>=</c-> encoder<c- p>.</c->encode<c- p>(</c->strings<c- p>[</c->i<c- p>]);</c->
    len <c- o>+=</c-> encoded<c- p>[</c->i<c- p>].</c->byteLength<c- p>;</c->
  <c- p>}</c->

  bytes <c- o>=</c-> <c- k>new</c-> Uint8Array<c- p>(</c->len<c- p>);</c->
  view <c- o>=</c-> <c- k>new</c-> DataView<c- p>(</c->bytes<c- p>.</c->buffer<c- p>);</c->
  offset <c- o>=</c-> <c- mi>0</c-><c- p>;</c->

  view<c- p>.</c->setUint32<c- p>(</c->offset<c- p>,</c-> strings<c- p>.</c->length<c- p>);</c->
  offset <c- o>+=</c-> Uint32Array<c- p>.</c->BYTES_PER_ELEMENT<c- p>;</c->
  <c- k>for</c-> <c- p>(</c-><c- a>var</c-> i <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> i <c- o>&lt;</c-> encoded<c- p>.</c->length<c- p>;</c-> i <c- o>+=</c-> <c- mi>1</c-><c- p>)</c-> <c- p>{</c->
    len <c- o>=</c-> encoded<c- p>[</c->i<c- p>].</c->byteLength<c- p>;</c->
    view<c- p>.</c->setUint32<c- p>(</c->offset<c- p>,</c-> len<c- p>);</c->
    offset <c- o>+=</c-> Uint32Array<c- p>.</c->BYTES_PER_ELEMENT<c- p>;</c->
    bytes<c- p>.</c->set<c- p>(</c->encoded<c- p>[</c->i<c- p>],</c-> offset<c- p>);</c->
    offset <c- o>+=</c-> len<c- p>;</c->
  <c- p>}</c->
  <c- k>return</c-> bytes<c- p>.</c->buffer<c- p>;</c->
<c- p>}</c-></code></pre>
    <p>The following example decodes an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-ArrayBuffer" id="ref-for-idl-ArrayBuffer①">ArrayBuffer</a></code> containing data encoded in the
 format produced by the previous example, or an equivalent algorithm for encodings other than <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①④">UTF-8</a>, back into an array of strings. </p>
<pre><code class="lang-javascript highlight"><c- a>function</c-> decodeArrayOfStrings<c- p>(</c->buffer<c- p>,</c-> encoding<c- p>)</c-> <c- p>{</c->
  <c- a>var</c-> decoder<c- p>,</c-> view<c- p>,</c-> offset<c- p>,</c-> num_strings<c- p>,</c-> strings<c- p>,</c-> len<c- p>;</c->

  decoder <c- o>=</c-> <c- k>new</c-> TextDecoder<c- p>(</c->encoding<c- p>);</c->
  view <c- o>=</c-> <c- k>new</c-> DataView<c- p>(</c->buffer<c- p>);</c->
  offset <c- o>=</c-> <c- mi>0</c-><c- p>;</c->
  strings <c- o>=</c-> <c- p>[];</c->

  num_strings <c- o>=</c-> view<c- p>.</c->getUint32<c- p>(</c->offset<c- p>);</c->
  offset <c- o>+=</c-> Uint32Array<c- p>.</c->BYTES_PER_ELEMENT<c- p>;</c->
  <c- k>for</c-> <c- p>(</c-><c- a>var</c-> i <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> i <c- o>&lt;</c-> num_strings<c- p>;</c-> i<c- o>++</c-><c- p>)</c-> <c- p>{</c->
    len <c- o>=</c-> view<c- p>.</c->getUint32<c- p>(</c->offset<c- p>);</c->
    offset <c- o>+=</c-> Uint32Array<c- p>.</c->BYTES_PER_ELEMENT<c- p>;</c->
    strings<c- p>[</c->i<c- p>]</c-> <c- o>=</c-> decoder<c- p>.</c->decode<c- p>(</c->
      <c- k>new</c-> DataView<c- p>(</c->view<c- p>.</c->buffer<c- p>,</c-> offset<c- p>,</c-> len<c- p>));</c->
    offset <c- o>+=</c-> len<c- p>;</c->
  <c- p>}</c->
  <c- k>return</c-> strings<c- p>;</c->
<c- p>}</c-></code></pre>
   </div>
   <h3 class="heading settled" data-level="7.1" id="interface-mixin-textdecodercommon"><span class="secno">7.1. </span><span class="content">Interface mixin <code class="idl"><a data-link-type="idl" href="#textdecodercommon" id="ref-for-textdecodercommon">TextDecoderCommon</a></code></span><a class="self-link" href="#interface-mixin-textdecodercommon"></a></h3>
<pre class="idl highlight def"><c- b>interface</c-> <c- b>mixin</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="textdecodercommon"><code><c- g>TextDecoderCommon</c-></code></dfn> {
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString"><c- b>DOMString</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="DOMString" href="#dom-textdecoder-encoding" id="ref-for-dom-textdecoder-encoding"><c- g>encoding</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean"><c- b>boolean</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="boolean" href="#dom-textdecoder-fatal" id="ref-for-dom-textdecoder-fatal"><c- g>fatal</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean①"><c- b>boolean</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="boolean" href="#dom-textdecoder-ignorebom" id="ref-for-dom-textdecoder-ignorebom"><c- g>ignoreBOM</c-></a>;
};
</pre>
   <p>The <code class="idl"><a data-link-type="idl" href="#textdecodercommon" id="ref-for-textdecodercommon①">TextDecoderCommon</a></code> interface mixin defines common attributes that are shared between <code class="idl"><a data-link-type="idl" href="#textdecoder" id="ref-for-textdecoder">TextDecoder</a></code> and <code class="idl"><a data-link-type="idl" href="#textdecoderstream" id="ref-for-textdecoderstream">TextDecoderStream</a></code> objects. These objects have an associated <dfn class="dfn-paneled" data-dfn-for="TextDecoderCommon" data-dfn-type="dfn" data-noexport id="textdecoder-encoding">encoding</dfn>, <dfn class="dfn-paneled" data-dfn-for="TextDecoderCommon" data-dfn-type="dfn" data-noexport id="textdecoder-ignore-bom-flag">ignore BOM flag</dfn> (initially unset), <dfn class="dfn-paneled" data-dfn-for="TextDecoderCommon" data-dfn-type="dfn" data-noexport id="textdecoder-bom-seen-flag">BOM seen flag</dfn> (initially unset), and <dfn class="dfn-paneled" data-dfn-for="TextDecoderCommon" data-dfn-type="dfn" data-noexport id="textdecoder-error-mode">error mode</dfn> (initially
"<code>replacement</code>"). </p>
   <p>These objects also have an associated <dfn class="dfn-paneled" data-dfn-for="TextDecoderCommon" data-dfn-type="dfn" data-noexport id="concept-td-serialize">serialize stream</dfn> algorithm, that given a <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①③">stream</a> <var>stream</var>, runs these steps: </p>
   <ol>
    <li>
     <p>Let <var>output</var> be the empty string. </p>
    <li>
     <p>While true: </p>
     <ol>
      <li>
       <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read④">reading</a> from <var>stream</var>. </p>
      <li>
       <p>If <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding">encoding</a> is <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①⑤">UTF-8</a>, <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be⑧">UTF-16BE</a>, or <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le⑧">UTF-16LE</a>, and <a data-link-type="dfn" href="#textdecoder-ignore-bom-flag" id="ref-for-textdecoder-ignore-bom-flag">ignore BOM flag</a> and <a data-link-type="dfn" href="#textdecoder-bom-seen-flag" id="ref-for-textdecoder-bom-seen-flag">BOM seen flag</a> are unset, then: </p>
       <ol>
        <li>
         <p>If <var>token</var> is U+FEFF, then set <a data-link-type="dfn" href="#textdecoder-bom-seen-flag" id="ref-for-textdecoder-bom-seen-flag①">BOM seen flag</a>. </p>
        <li>
         <p>Otherwise, if <var>token</var> is not <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②">end-of-stream</a>, then set <a data-link-type="dfn" href="#textdecoder-bom-seen-flag" id="ref-for-textdecoder-bom-seen-flag②">BOM seen flag</a> and append <var>token</var> to <var>output</var>. </p>
        <li>
         <p>Otherwise, return <var>output</var>. </p>
       </ol>
      <li>
       <p>Otherwise, if <var>token</var> is not <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③">end-of-stream</a>, then append <var>token</var> to <var>output</var>. </p>
      <li>
       <p>Otherwise, return <var>output</var>. </p>
     </ol>
   </ol>
   <p class="note" role="note">This algorithm is intentionally different with respect to BOM handling from
the <a data-link-type="dfn" href="#decode" id="ref-for-decode②">decode</a> algorithm used by the rest of the platform to give API users more
control. </p>
   <hr>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextDecoderCommon" data-dfn-type="attribute" data-export id="dom-textdecoder-encoding"><code>encoding</code></dfn> attribute’s getter, when invoked, must return this object’s <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding①">encoding</a>’s <a data-link-type="dfn" href="#name" id="ref-for-name③">name</a> in <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-lowercase" id="ref-for-ascii-lowercase①">ASCII lowercase</a>. </p>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextDecoderCommon" data-dfn-type="attribute" data-export id="dom-textdecoder-fatal"><code>fatal</code></dfn> attribute’s getter, when invoked, must return true if this object’s <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode">error mode</a> is "<code>fatal</code>", and false otherwise. </p>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextDecoderCommon" data-dfn-type="attribute" data-export id="dom-textdecoder-ignorebom"><code>ignoreBOM</code></dfn> attribute’s getter, when invoked, must return true if this object’s <a data-link-type="dfn" href="#textdecoder-ignore-bom-flag" id="ref-for-textdecoder-ignore-bom-flag①">ignore BOM flag</a> is set, and false otherwise. </p>
   <h3 class="heading settled" data-level="7.2" id="interface-textdecoder"><span class="secno">7.2. </span><span class="content">Interface <code class="idl"><a data-link-type="idl" href="#textdecoder" id="ref-for-textdecoder①">TextDecoder</a></code></span><a class="self-link" href="#interface-textdecoder"></a></h3>
<pre class="idl highlight def"><c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="textdecoderoptions"><code><c- g>TextDecoderOptions</c-></code></dfn> {
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean②"><c- b>boolean</c-></a> <dfn class="idl-code" data-default="false" data-dfn-for="TextDecoderOptions" data-dfn-type="dict-member" data-export data-type="boolean " id="dom-textdecoderoptions-fatal"><code><c- g>fatal</c-></code><a class="self-link" href="#dom-textdecoderoptions-fatal"></a></dfn> = <c- b>false</c->;
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean③"><c- b>boolean</c-></a> <dfn class="idl-code" data-default="false" data-dfn-for="TextDecoderOptions" data-dfn-type="dict-member" data-export data-type="boolean " id="dom-textdecoderoptions-ignorebom"><code><c- g>ignoreBOM</c-></code><a class="self-link" href="#dom-textdecoderoptions-ignorebom"></a></dfn> = <c- b>false</c->;
};

<c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="textdecodeoptions"><code><c- g>TextDecodeOptions</c-></code></dfn> {
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean④"><c- b>boolean</c-></a> <dfn class="idl-code" data-default="false" data-dfn-for="TextDecodeOptions" data-dfn-type="dict-member" data-export data-type="boolean " id="dom-textdecodeoptions-stream"><code><c- g>stream</c-></code><a class="self-link" href="#dom-textdecodeoptions-stream"></a></dfn> = <c- b>false</c->;
};

[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="textdecoder"><code><c- g>TextDecoder</c-></code></dfn> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textdecoder" id="ref-for-dom-textdecoder"><c- g>constructor</c-></a>(<c- b>optional</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString①"><c- b>DOMString</c-></a> <dfn class="idl-code" data-dfn-for="TextDecoder/TextDecoder(label, options), TextDecoder/constructor(label, options), TextDecoder/TextDecoder(label), TextDecoder/constructor(label), TextDecoder/TextDecoder(), TextDecoder/constructor()" data-dfn-type="argument" data-export id="dom-textdecoder-textdecoder-label-options-label"><code><c- g>label</c-></code><a class="self-link" href="#dom-textdecoder-textdecoder-label-options-label"></a></dfn> = "utf-8", <c- b>optional</c-> <a class="n" data-link-type="idl-name" href="#textdecoderoptions" id="ref-for-textdecoderoptions"><c- n>TextDecoderOptions</c-></a> <dfn class="idl-code" data-dfn-for="TextDecoder/TextDecoder(label, options), TextDecoder/constructor(label, options), TextDecoder/TextDecoder(label), TextDecoder/constructor(label), TextDecoder/TextDecoder(), TextDecoder/constructor()" data-dfn-type="argument" data-export id="dom-textdecoder-textdecoder-label-options-options"><code><c- g>options</c-></code><a class="self-link" href="#dom-textdecoder-textdecoder-label-options-options"></a></dfn> = {});

  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-USVString" id="ref-for-idl-USVString"><c- b>USVString</c-></a> <a class="idl-code" data-link-type="method" href="#dom-textdecoder-decode" id="ref-for-dom-textdecoder-decode"><c- g>decode</c-></a>(<c- b>optional</c-> [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#AllowShared" id="ref-for-AllowShared"><c- g>AllowShared</c-></a>] <a class="n" data-link-type="idl-name" href="https://heycam.github.io/webidl/#BufferSource" id="ref-for-BufferSource"><c- n>BufferSource</c-></a> <dfn class="idl-code" data-dfn-for="TextDecoder/decode(input, options), TextDecoder/decode(input), TextDecoder/decode()" data-dfn-type="argument" data-export id="dom-textdecoder-decode-input-options-input"><code><c- g>input</c-></code><a class="self-link" href="#dom-textdecoder-decode-input-options-input"></a></dfn>, <c- b>optional</c-> <a class="n" data-link-type="idl-name" href="#textdecodeoptions" id="ref-for-textdecodeoptions"><c- n>TextDecodeOptions</c-></a> <dfn class="idl-code" data-dfn-for="TextDecoder/decode(input, options), TextDecoder/decode(input), TextDecoder/decode()" data-dfn-type="argument" data-export id="dom-textdecoder-decode-input-options-options"><code><c- g>options</c-></code><a class="self-link" href="#dom-textdecoder-decode-input-options-options"></a></dfn> = {});
};
<a class="n" data-link-type="idl-name" href="#textdecoder" id="ref-for-textdecoder②"><c- n>TextDecoder</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textdecodercommon" id="ref-for-textdecodercommon②"><c- n>TextDecoderCommon</c-></a>;
</pre>
   <p>A <code class="idl"><a data-link-type="idl" href="#textdecoder" id="ref-for-textdecoder③">TextDecoder</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-for="TextDecoder" data-dfn-type="dfn" data-noexport id="textdecoder-decoder">decoder</dfn>, <dfn class="dfn-paneled" data-dfn-for="TextDecoder" data-dfn-type="dfn" data-noexport id="textdecoder-stream">stream</dfn>, and <dfn class="dfn-paneled" data-dfn-for="TextDecoder" data-dfn-type="dfn" data-noexport id="textdecoder-do-not-flush-flag">do not flush flag</dfn> (initially
unset). </p>
   <dl class="domintro">
    <dt><code><var>decoder</var> = new <a class="idl-code" data-link-type="constructor" href="#dom-textdecoder" id="ref-for-dom-textdecoder①">TextDecoder([<var>label</var> = "utf-8" [, <var>options</var>]])</a></code> 
    <dd>
     <p>Returns a new <code class="idl"><a data-link-type="idl" href="#textdecoder" id="ref-for-textdecoder④">TextDecoder</a></code> object. </p>
     <p>If <var>label</var> is either not a <a data-link-type="dfn" href="#label" id="ref-for-label①⓪">label</a> or is a <a data-link-type="dfn" href="#label" id="ref-for-label①①">label</a> for <a data-link-type="dfn" href="#replacement" id="ref-for-replacement⑤">replacement</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw" id="ref-for-dfn-throw">throws</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-rangeerror" id="ref-for-exceptiondef-rangeerror">RangeError</a></code>. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textdecoder-encoding" id="ref-for-dom-textdecoder-encoding①">encoding</a></code> 
    <dd>
     <p>Returns <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding②">encoding</a>’s <a data-link-type="dfn" href="#name" id="ref-for-name④">name</a>, lowercased. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textdecoder-fatal" id="ref-for-dom-textdecoder-fatal①">fatal</a></code> 
    <dd>
     <p>Returns true if <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode①">error mode</a> is "<code>fatal</code>", and
 false otherwise. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textdecoder-ignorebom" id="ref-for-dom-textdecoder-ignorebom①">ignoreBOM</a></code> 
    <dd>
     <p>Returns true if <a data-link-type="dfn" href="#textdecoder-ignore-bom-flag" id="ref-for-textdecoder-ignore-bom-flag②">ignore BOM flag</a> is set, and false
 otherwise. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="method" href="#dom-textdecoder-decode" id="ref-for-dom-textdecoder-decode①">decode([<var>input</var> [, <var>options</var>]])</a></code> 
    <dd>
     <p>Returns the result of running <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding③">encoding</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①①">decoder</a>.
  The method can be invoked zero or more times with <var>options</var>’s <code>stream</code> set to
  true, and then once without <var>options</var>’s <code>stream</code> (or set to false), to process
  a fragmented stream. If the invocation without <var>options</var>’s <code>stream</code> (or set to
  false) has no <var>input</var>, it’s clearest to omit both arguments. </p>
<pre class="example" id="example-end-of-stream"><a class="self-link" href="#example-end-of-stream"></a><code class="lang-javascript highlight"><c- a>var</c-> string <c- o>=</c-> <c- u>""</c-><c- p>,</c-> decoder <c- o>=</c-> <c- k>new</c-> TextDecoder<c- p>(</c->encoding<c- p>),</c-> buffer<c- p>;</c->
<c- k>while</c-><c- p>(</c->buffer <c- o>=</c-> next_chunk<c- p>())</c-> <c- p>{</c->
  string <c- o>+=</c-> decoder<c- p>.</c->decode<c- p>(</c->buffer<c- p>,</c-> <c- p>{</c->stream<c- o>:</c-><c- kc>true</c-><c- p>});</c->
<c- p>}</c->
string <c- o>+=</c-> decoder<c- p>.</c->decode<c- p>();</c-> <c- c1>// end-of-stream</c-></code></pre>
     <p>If the <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode②">error mode</a> is "<code>fatal</code>" and <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding④">encoding</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①②">decoder</a> returns <a data-link-type="dfn" href="#error" id="ref-for-error④">error</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw" id="ref-for-dfn-throw①">throws</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror">TypeError</a></code>. </p>
   </dl>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextDecoder" data-dfn-type="constructor" data-export data-lt="TextDecoder(label, options)|constructor(label, options)|TextDecoder(label)|constructor(label)|TextDecoder()|constructor()" id="dom-textdecoder"><code>TextDecoder(<var>label</var>, <var>options</var>)</code></dfn> constructor, when invoked, must run these steps: </p>
   <ol>
    <li>
     <p>Let <var>encoding</var> be the result of <a data-link-type="dfn" href="#concept-encoding-get" id="ref-for-concept-encoding-get①">getting an encoding</a> from <var>label</var>. </p>
    <li>
     <p>If <var>encoding</var> is failure or <a data-link-type="dfn" href="#replacement" id="ref-for-replacement⑥">replacement</a>, then <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw" id="ref-for-dfn-throw②">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-rangeerror" id="ref-for-exceptiondef-rangeerror①">RangeError</a></code>. </p>
    <li>
     <p>Let <var>dec</var> be a new <code class="idl"><a data-link-type="idl" href="#textdecoder" id="ref-for-textdecoder⑤">TextDecoder</a></code> object. </p>
    <li>
     <p>Set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding⑤">encoding</a> to <var>encoding</var>. </p>
    <li>
     <p>If <var>options</var>’s <code>fatal</code> member is true, then set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode③">error mode</a> to "<code>fatal</code>". </p>
    <li>
     <p>If <var>options</var>’s <code>ignoreBOM</code> member is true, then set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-ignore-bom-flag" id="ref-for-textdecoder-ignore-bom-flag③">ignore BOM flag</a>. </p>
    <li>
     <p>Return <var>dec</var>. </p>
   </ol>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextDecoder" data-dfn-type="method" data-export data-lt="decode(input, options)|decode(input)|decode()" id="dom-textdecoder-decode"><code>decode(<var>input</var>, <var>options</var>)</code></dfn> method, when invoked, must run these steps: </p>
   <ol>
    <li>
     <p>If the <a data-link-type="dfn" href="#textdecoder-do-not-flush-flag" id="ref-for-textdecoder-do-not-flush-flag">do not flush flag</a> is unset, set <a data-link-type="dfn" href="#textdecoder-decoder" id="ref-for-textdecoder-decoder">decoder</a> to a new <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding⑥">encoding</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①③">decoder</a>, set <a data-link-type="dfn" href="#textdecoder-stream" id="ref-for-textdecoder-stream">stream</a> to a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①④">stream</a>, and unset the <a data-link-type="dfn" href="#textdecoder-bom-seen-flag" id="ref-for-textdecoder-bom-seen-flag③">BOM seen flag</a>. </p>
    <li>
     <p>If <var>options</var>’s <code>stream</code> is true, set the <a data-link-type="dfn" href="#textdecoder-do-not-flush-flag" id="ref-for-textdecoder-do-not-flush-flag①">do not flush flag</a>, and unset the <a data-link-type="dfn" href="#textdecoder-do-not-flush-flag" id="ref-for-textdecoder-do-not-flush-flag②">do not flush flag</a> otherwise. </p>
    <li>
     <p>If <var>input</var> is given, then <a data-link-type="dfn" href="#concept-stream-push" id="ref-for-concept-stream-push②">push</a> a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-get-buffer-source-copy" id="ref-for-dfn-get-buffer-source-copy">copy of</a> <var>input</var> to <a data-link-type="dfn" href="#textdecoder-stream" id="ref-for-textdecoder-stream①">stream</a>. </p>
     <p class="note" role="note">Implementations are strongly encouraged to use an implementation strategy that
  avoids this copy. When doing so they will have to make sure that changes to <var>input</var> do
  not affect future calls to <a class="idl-code" data-link-type="method" href="#dom-textdecoder-decode" id="ref-for-dom-textdecoder-decode②"><code>decode()</code></a>. </p>
     <p class="warning" id="sharedarraybuffer-warning">The memory exposed by <code>SharedArrayBuffer</code> objects does not adhere to data race freedom properties required by the memory model of
  programming languages typically used for implementations. When implementing, take care to use the
  appropriate facilities when accessing memory exposed by <code>SharedArrayBuffer</code> objects. </p>
    <li>
     <p>Let <var>output</var> be a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①⑤">stream</a>. </p>
    <li>
     <p>While true: </p>
     <ol>
      <li>
       <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read⑤">reading</a> from <a data-link-type="dfn" href="#textdecoder-stream" id="ref-for-textdecoder-stream②">stream</a>. </p>
      <li>
       <p>If <var>token</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream④">end-of-stream</a> and the <a data-link-type="dfn" href="#textdecoder-do-not-flush-flag" id="ref-for-textdecoder-do-not-flush-flag③">do not flush flag</a> is set, then return <var>output</var>, <a data-link-type="dfn" href="#concept-td-serialize" id="ref-for-concept-td-serialize">serialized</a>. </p>
       <p class="note" role="note">The way streaming works is to not handle <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream⑤">end-of-stream</a> here when the <a data-link-type="dfn" href="#textdecoder-do-not-flush-flag" id="ref-for-textdecoder-do-not-flush-flag④">do not flush flag</a> is set and to not unset that flag. That way in a
    subsequent invocation <a data-link-type="dfn" href="#textdecoder-decoder" id="ref-for-textdecoder-decoder①">decoder</a> is not set anew in the first step of the
    algorithm and its state is preserved. </p>
      <li>
       <p>Otherwise: </p>
       <ol>
        <li>
         <p>Let <var>result</var> be the result of <a data-link-type="dfn" href="#concept-encoding-process" id="ref-for-concept-encoding-process①">processing</a> <var>token</var> for <a data-link-type="dfn" href="#textdecoder-decoder" id="ref-for-textdecoder-decoder②">decoder</a>, <a data-link-type="dfn" href="#textdecoder-stream" id="ref-for-textdecoder-stream③">stream</a>, <var>output</var>, and <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode④">error mode</a>. </p>
        <li>
         <p>If <var>result</var> is <a data-link-type="dfn" href="#finished" id="ref-for-finished①">finished</a>, then return <var>output</var>, <a data-link-type="dfn" href="#concept-td-serialize" id="ref-for-concept-td-serialize①">serialized</a>. </p>
        <li>
         <p>Otherwise, if <var>result</var> is <a data-link-type="dfn" href="#error" id="ref-for-error⑤">error</a>, then <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw" id="ref-for-dfn-throw③">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror①">TypeError</a></code>. </p>
       </ol>
     </ol>
   </ol>
   <h3 class="heading settled" data-level="7.3" id="interface-mixin-textencodercommon"><span class="secno">7.3. </span><span class="content">Interface mixin <code class="idl"><a data-link-type="idl" href="#textencodercommon" id="ref-for-textencodercommon">TextEncoderCommon</a></code></span><a class="self-link" href="#interface-mixin-textencodercommon"></a></h3>
<pre class="idl highlight def"><c- b>interface</c-> <c- b>mixin</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="textencodercommon"><code><c- g>TextEncoderCommon</c-></code></dfn> {
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString②"><c- b>DOMString</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="DOMString" href="#dom-textencoder-encoding" id="ref-for-dom-textencoder-encoding"><c- g>encoding</c-></a>;
};
</pre>
   <p>The <code class="idl"><a data-link-type="idl" href="#textencodercommon" id="ref-for-textencodercommon①">TextEncoderCommon</a></code> interface mixin defines common attributes that are shared between <code class="idl"><a data-link-type="idl" href="#textencoder" id="ref-for-textencoder①">TextEncoder</a></code> and <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream">TextEncoderStream</a></code> objects. </p>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextEncoderCommon" data-dfn-type="attribute" data-export id="dom-textencoder-encoding"><code>encoding</code></dfn> attribute’s getter, when invoked, must return "<code>utf-8</code>". </p>
   <h3 class="heading settled" data-level="7.4" id="interface-textencoder"><span class="secno">7.4. </span><span class="content">Interface <code class="idl"><a data-link-type="idl" href="#textencoder" id="ref-for-textencoder②">TextEncoder</a></code></span><a class="self-link" href="#interface-textencoder"></a></h3>
<pre class="idl highlight def"><c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="dictdef-textencoderencodeintoresult"><code><c- g>TextEncoderEncodeIntoResult</c-></code></dfn> {
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-unsigned-long-long" id="ref-for-idl-unsigned-long-long"><c- b>unsigned</c-> <c- b>long</c-> <c- b>long</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="TextEncoderEncodeIntoResult" data-dfn-type="dict-member" data-export data-type="unsigned long long " id="dom-textencoderencodeintoresult-read"><code><c- g>read</c-></code></dfn>;
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-unsigned-long-long" id="ref-for-idl-unsigned-long-long①"><c- b>unsigned</c-> <c- b>long</c-> <c- b>long</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="TextEncoderEncodeIntoResult" data-dfn-type="dict-member" data-export data-type="unsigned long long " id="dom-textencoderencodeintoresult-written"><code><c- g>written</c-></code></dfn>;
};

[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed①"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="textencoder"><code><c- g>TextEncoder</c-></code></dfn> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textencoder" id="ref-for-dom-textencoder"><c- g>constructor</c-></a>();

  [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject" id="ref-for-NewObject"><c- g>NewObject</c-></a>] <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array①"><c- b>Uint8Array</c-></a> <a class="idl-code" data-link-type="method" href="#dom-textencoder-encode" id="ref-for-dom-textencoder-encode"><c- g>encode</c-></a>(<c- b>optional</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-USVString" id="ref-for-idl-USVString①"><c- b>USVString</c-></a> <dfn class="idl-code" data-dfn-for="TextEncoder/encode(input), TextEncoder/encode()" data-dfn-type="argument" data-export id="dom-textencoder-encode-input-input"><code><c- g>input</c-></code><a class="self-link" href="#dom-textencoder-encode-input-input"></a></dfn> = "");
  <a class="n" data-link-type="idl-name" href="#dictdef-textencoderencodeintoresult" id="ref-for-dictdef-textencoderencodeintoresult"><c- n>TextEncoderEncodeIntoResult</c-></a> <a class="idl-code" data-link-type="method" href="#dom-textencoder-encodeinto" id="ref-for-dom-textencoder-encodeinto"><c- g>encodeInto</c-></a>(<a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-USVString" id="ref-for-idl-USVString②"><c- b>USVString</c-></a> <dfn class="idl-code" data-dfn-for="TextEncoder/encodeInto(source, destination)" data-dfn-type="argument" data-export id="dom-textencoder-encodeinto-source-destination-source"><code><c- g>source</c-></code><a class="self-link" href="#dom-textencoder-encodeinto-source-destination-source"></a></dfn>, [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#AllowShared" id="ref-for-AllowShared①"><c- g>AllowShared</c-></a>] <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array②"><c- b>Uint8Array</c-></a> <dfn class="idl-code" data-dfn-for="TextEncoder/encodeInto(source, destination)" data-dfn-type="argument" data-export id="dom-textencoder-encodeinto-source-destination-destination"><code><c- g>destination</c-></code><a class="self-link" href="#dom-textencoder-encodeinto-source-destination-destination"></a></dfn>);
};
<a class="n" data-link-type="idl-name" href="#textencoder" id="ref-for-textencoder③"><c- n>TextEncoder</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textencodercommon" id="ref-for-textencodercommon②"><c- n>TextEncoderCommon</c-></a>;
</pre>
   <p class="note no-backref" role="note">A <code class="idl"><a data-link-type="idl" href="#textencoder" id="ref-for-textencoder④">TextEncoder</a></code> object offers no <var>label</var> argument as it only
supports <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①⑥">UTF-8</a>. It also offers no <code>stream</code> option as no <a data-link-type="dfn" href="#encoder" id="ref-for-encoder⑧">encoder</a> requires buffering of scalar values. </p>
   <hr>
   <dl class="domintro">
    <dt><code><var>encoder</var> = new <a class="idl-code" data-link-type="constructor" href="#dom-textencoder" id="ref-for-dom-textencoder①">TextEncoder()</a></code> 
    <dd>
     <p>Returns a new <code class="idl"><a data-link-type="idl" href="#textencoder" id="ref-for-textencoder⑤">TextEncoder</a></code> object. </p>
    <dt><code><var>encoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textencoder-encoding" id="ref-for-dom-textencoder-encoding①">encoding</a></code> 
    <dd>
     <p>Returns "<code>utf-8</code>". </p>
    <dt><code><var>encoder</var> . <a class="idl-code" data-link-type="method" href="#dom-textencoder-encode" id="ref-for-dom-textencoder-encode①">encode([<var>input</var> = ""])</a></code> 
    <dd>
     <p>Returns the result of running <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①⑦">UTF-8</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder⑨">encoder</a>. </p>
    <dt><code><var>encoder</var> . <a class="idl-code" data-link-type="method" href="#dom-textencoder-encodeinto" id="ref-for-dom-textencoder-encodeinto①">encodeInto(<var>source</var>, <var>destination</var>)</a></code> 
    <dd>
     <p>Runs the <a data-link-type="dfn" href="#utf-8-encoder" id="ref-for-utf-8-encoder">UTF-8 encoder</a> on <var>source</var>, stores the result of that operation into <var>destination</var>, and returns the progress made as a dictionary whereby <code class="idl"><a data-link-type="idl" href="#dom-textencoderencodeintoresult-read" id="ref-for-dom-textencoderencodeintoresult-read">read</a></code> is the number of converted <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#code-unit" id="ref-for-code-unit">code units</a> of <var>source</var> and <code class="idl"><a data-link-type="idl" href="#dom-textencoderencodeintoresult-written" id="ref-for-dom-textencoderencodeintoresult-written">written</a></code> is the number of bytes modified in <var>destination</var>. </p>
   </dl>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextEncoder" data-dfn-type="constructor" data-export data-lt="TextEncoder()|constructor()" id="dom-textencoder"><code>TextEncoder()</code></dfn> constructor, when invoked, must return a new <code class="idl"><a data-link-type="idl" href="#textencoder" id="ref-for-textencoder⑥">TextEncoder</a></code> object. </p>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextEncoder" data-dfn-type="method" data-export data-lt="encode(input)|encode()" id="dom-textencoder-encode"><code>encode(<var>input</var>)</code></dfn> method, when invoked,
must run these steps: </p>
   <ol>
    <li>
     <p>Convert <var>input</var> to a <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①⑥">stream</a>. </p>
    <li>
     <p>Let <var>output</var> be a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①⑦">stream</a>. </p>
    <li>
     <p>While true: </p>
     <ol>
      <li>
       <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read⑥">reading</a> from <var>input</var>. </p>
      <li>
       <p>Let <var>result</var> be the result of <a data-link-type="dfn" href="#concept-encoding-process" id="ref-for-concept-encoding-process②">processing</a> <var>token</var> for the <a data-link-type="dfn" href="#utf-8-encoder" id="ref-for-utf-8-encoder①">UTF-8 encoder</a>, <var>input</var>, <var>output</var>. </p>
      <li>
       <p>Assert: <var>result</var> is not <a data-link-type="dfn" href="#error" id="ref-for-error⑥">error</a>. </p>
       <p class="note" role="note">The <a data-link-type="dfn" href="#utf-8-encoder" id="ref-for-utf-8-encoder②">UTF-8 encoder</a> cannot return <a data-link-type="dfn" href="#error" id="ref-for-error⑦">error</a>. </p>
      <li>
       <p>If <var>result</var> is <a data-link-type="dfn" href="#finished" id="ref-for-finished②">finished</a>, convert <var>output</var> into a byte sequence,
   and then return a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array③">Uint8Array</a></code> object wrapping an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-ArrayBuffer" id="ref-for-idl-ArrayBuffer②">ArrayBuffer</a></code> containing <var>output</var>. </p>
     </ol>
   </ol>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextEncoder" data-dfn-type="method" data-export id="dom-textencoder-encodeinto"><code>encodeInto(<var>source</var>, <var>destination</var>)</code></dfn> method, when invoked, must run these steps: </p>
   <ol>
    <li>
     <p>Let <var>read</var> be 0. </p>
    <li>
     <p>Let <var>written</var> be 0. </p>
    <li>
     <p>Let <var>destinationBytes</var> be the result of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-get-buffer-source-reference" id="ref-for-dfn-get-buffer-source-reference">getting a reference to the bytes held by</a> <var>destination</var>. </p>
    <li>
     <p>Let <var>unused</var> be a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①⑧">stream</a>. </p>
     <p class="note" role="note">The <a data-link-type="dfn" href="#handler" id="ref-for-handler②">handler</a> algorithm invoked below requires this argument, but it is not
  used by the <a data-link-type="dfn" href="#utf-8-encoder" id="ref-for-utf-8-encoder③">UTF-8 encoder</a>. </p>
    <li>
     <p>Convert <var>source</var> to a <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream①⑨">stream</a>. </p>
    <li>
     <p>While true: </p>
     <ol>
      <li>
       <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read⑦">reading</a> from <var>source</var>. </p>
      <li>
       <p>Let <var>result</var> be the result of running the <a data-link-type="dfn" href="#utf-8-encoder" id="ref-for-utf-8-encoder④">UTF-8 encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler③">handler</a> on <var>unused</var> and <var>token</var>. </p>
      <li>
       <p>If <var>result</var> is <a data-link-type="dfn" href="#finished" id="ref-for-finished③">finished</a>, then <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#iteration-break" id="ref-for-iteration-break">break</a>. </p>
      <li>
       <p>Otherwise: </p>
       <ol>
        <li>
         <p>If <var>destinationBytes</var>’s <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#byte-sequence-length" id="ref-for-byte-sequence-length">length</a> − <var>written</var> is greater than or equal to the number of bytes in <var>result</var>, then: </p>
         <ol>
          <li>
           <p>If <var>token</var> is greater than U+FFFF, then increment <var>read</var> by 2. </p>
          <li>
           <p>Otherwise, increment <var>read</var> by 1. </p>
          <li>
           <p>Write the bytes in <var>result</var> into <var>destinationBytes</var>, from byte offset <var>written</var>. </p>
           <p class="warning">See the <a href="#sharedarraybuffer-warning">warning for <code>SharedArrayBuffer</code> objects</a> above. </p>
          <li>
           <p>Increment <var>written</var> by the number of bytes in <var>result</var>. </p>
         </ol>
        <li>
         <p>Otherwise, <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#iteration-break" id="ref-for-iteration-break①">break</a>. </p>
       </ol>
     </ol>
    <li>
     <p>Return a new <code class="idl"><a data-link-type="idl" href="#dictdef-textencoderencodeintoresult" id="ref-for-dictdef-textencoderencodeintoresult①">TextEncoderEncodeIntoResult</a></code> dictionary whose <code class="idl"><a data-link-type="idl" href="#dom-textencoderencodeintoresult-read" id="ref-for-dom-textencoderencodeintoresult-read①">read</a></code> member is <var>read</var> and <code class="idl"><a data-link-type="idl" href="#dom-textencoderencodeintoresult-written" id="ref-for-dom-textencoderencodeintoresult-written①">written</a></code> member is <var>written</var>. </p>
   </ol>
   <div class="example" id="example-textencoder-encodeinto">
    <a class="self-link" href="#example-textencoder-encodeinto"></a> 
    <p>The <a class="idl-code" data-link-type="method" href="#dom-textencoder-encodeinto" id="ref-for-dom-textencoder-encodeinto②">encodeInto()</a> method can
 be used to encode a string into an existing <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-ArrayBuffer" id="ref-for-idl-ArrayBuffer③">ArrayBuffer</a></code> object. Various details below are left
 as an exercise for the reader, but this demonstrates an approach one could take to use this method: </p>
<pre><code class="lang-javascript highlight"><c- a>function</c-> convertString<c- p>(</c->buffer<c- p>,</c-> input<c- p>,</c-> callback<c- p>)</c-> <c- p>{</c->
  <c- a>let</c-> bufferSize <c- o>=</c-> <c- mi>256</c-><c- p>,</c->
      bufferStart <c- o>=</c-> malloc<c- p>(</c->buffer<c- p>,</c-> bufferSize<c- p>),</c->
      writeOffset <c- o>=</c-> <c- mi>0</c-><c- p>,</c->
      readOffset <c- o>=</c-> <c- mi>0</c-><c- p>;</c->
  <c- k>while</c-> <c- p>(</c-><c- kc>true</c-><c- p>)</c-> <c- p>{</c->
    <c- kr>const</c-> view <c- o>=</c-> <c- k>new</c-> Uint8Array<c- p>(</c->buffer<c- p>,</c-> bufferStart <c- o>+</c-> writeOffset<c- p>,</c-> bufferSize <c- o>-</c-> writeOffset<c- p>),</c->
          <c- p>{</c->read<c- p>,</c-> written<c- p>}</c-> <c- o>=</c-> cachedEncoder<c- p>.</c->encodeInto<c- p>(</c->input<c- p>.</c->substring<c- p>(</c->readOffset<c- p>),</c-> view<c- p>);</c->
    readOffset <c- o>+=</c-> read<c- p>;</c->
    writeOffset <c- o>+=</c-> written<c- p>;</c->
    <c- k>if</c-> <c- p>(</c->readOffset <c- o>===</c-> input<c- p>.</c->length<c- p>)</c-> <c- p>{</c->
      callback<c- p>(</c->bufferStart<c- p>,</c-> writeOffset<c- p>);</c->
      free<c- p>(</c->buffer<c- p>,</c-> bufferStart<c- p>);</c->
      <c- k>return</c-><c- p>;</c->
    <c- p>}</c->
    bufferSize <c- o>*=</c-> <c- mi>2</c-><c- p>;</c->
    bufferStart <c- o>=</c-> realloc<c- p>(</c->buffer<c- p>,</c-> bufferStart<c- p>,</c-> bufferSize<c- p>);</c->
  <c- p>}</c->
<c- p>}</c->
</code></pre>
   </div>
   <h3 class="heading settled" data-level="7.5" id="interface-mixin-generictransformstream"><span class="secno">7.5. </span><span class="content">Interface mixin <code class="idl"><a data-link-type="idl" href="#generictransformstream" id="ref-for-generictransformstream">GenericTransformStream</a></code></span><a class="self-link" href="#interface-mixin-generictransformstream"></a></h3>
   <p>The <code class="idl"><a data-link-type="idl" href="#generictransformstream" id="ref-for-generictransformstream①">GenericTransformStream</a></code> interface mixin represents the concept of a <a data-link-type="dfn" href="https://streams.spec.whatwg.org/#transform-stream" id="ref-for-transform-stream">transform stream</a> in IDL. It is not a <code class="idl"><a data-link-type="idl" href="https://streams.spec.whatwg.org/#ts-class" id="ref-for-ts-class">TransformStream</a></code>, though it has the same interface
and it delegates to one. </p>
<pre class="idl highlight def"><c- b>interface</c-> <c- b>mixin</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="generictransformstream"><code><c- g>GenericTransformStream</c-></code></dfn> {
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="n" data-link-type="idl-name" href="https://streams.spec.whatwg.org/#rs-class" id="ref-for-rs-class"><c- n>ReadableStream</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="ReadableStream" href="#dom-generictransformstream-readable" id="ref-for-dom-generictransformstream-readable"><c- g>readable</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="n" data-link-type="idl-name" href="https://streams.spec.whatwg.org/#ws-class" id="ref-for-ws-class"><c- n>WritableStream</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="WritableStream" href="#dom-generictransformstream-writable" id="ref-for-dom-generictransformstream-writable"><c- g>writable</c-></a>;
};
</pre>
   <p>An object that includes <code class="idl"><a data-link-type="idl" href="#generictransformstream" id="ref-for-generictransformstream②">GenericTransformStream</a></code> has an associated <dfn class="dfn-paneled" data-dfn-for="GenericTransformStream" data-dfn-type="dfn" data-noexport id="generictransformstream-transform">transform</dfn> of type <code class="idl"><a data-link-type="idl" href="https://streams.spec.whatwg.org/#ts-class" id="ref-for-ts-class①">TransformStream</a></code>. </p>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="GenericTransformStream" data-dfn-type="attribute" data-export id="dom-generictransformstream-readable"><code>readable</code></dfn> attribute’s getter,
when invoked, must return this object’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform">transform</a>.[[readable]]. </p>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="GenericTransformStream" data-dfn-type="attribute" data-export id="dom-generictransformstream-writable"><code>writable</code></dfn> attribute’s getter,
when invoked, must return this object’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform①">transform</a>.[[writable]]. </p>
   <h3 class="heading settled" data-level="7.6" id="interface-textdecoderstream"><span class="secno">7.6. </span><span class="content">Interface <code class="idl"><a data-link-type="idl" href="#textdecoderstream" id="ref-for-textdecoderstream①">TextDecoderStream</a></code></span><a class="self-link" href="#interface-textdecoderstream"></a></h3>
<pre class="idl highlight def">[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed②"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="textdecoderstream"><code><c- g>TextDecoderStream</c-></code></dfn> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textdecoderstream" id="ref-for-dom-textdecoderstream"><c- g>constructor</c-></a>(<c- b>optional</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString③"><c- b>DOMString</c-></a> <dfn class="idl-code" data-dfn-for="TextDecoderStream/TextDecoderStream(label, options), TextDecoderStream/constructor(label, options), TextDecoderStream/TextDecoderStream(label), TextDecoderStream/constructor(label), TextDecoderStream/TextDecoderStream(), TextDecoderStream/constructor()" data-dfn-type="argument" data-export id="dom-textdecoderstream-textdecoderstream-label-options-label"><code><c- g>label</c-></code><a class="self-link" href="#dom-textdecoderstream-textdecoderstream-label-options-label"></a></dfn> = "utf-8", <c- b>optional</c-> <a class="n" data-link-type="idl-name" href="#textdecoderoptions" id="ref-for-textdecoderoptions①"><c- n>TextDecoderOptions</c-></a> <dfn class="idl-code" data-dfn-for="TextDecoderStream/TextDecoderStream(label, options), TextDecoderStream/constructor(label, options), TextDecoderStream/TextDecoderStream(label), TextDecoderStream/constructor(label), TextDecoderStream/TextDecoderStream(), TextDecoderStream/constructor()" data-dfn-type="argument" data-export id="dom-textdecoderstream-textdecoderstream-label-options-options"><code><c- g>options</c-></code><a class="self-link" href="#dom-textdecoderstream-textdecoderstream-label-options-options"></a></dfn> = {});
};
<a class="n" data-link-type="idl-name" href="#textdecoderstream" id="ref-for-textdecoderstream②"><c- n>TextDecoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textdecodercommon" id="ref-for-textdecodercommon③"><c- n>TextDecoderCommon</c-></a>;
<a class="n" data-link-type="idl-name" href="#textdecoderstream" id="ref-for-textdecoderstream③"><c- n>TextDecoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#generictransformstream" id="ref-for-generictransformstream③"><c- n>GenericTransformStream</c-></a>;
</pre>
   <p>A <code class="idl"><a data-link-type="idl" href="#textdecoderstream" id="ref-for-textdecoderstream④">TextDecoderStream</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-for="TextDecoderStream" data-dfn-type="dfn" data-noexport id="textdecoderstream-decoder">decoder</dfn>, and <dfn class="dfn-paneled" data-dfn-for="TextDecoderStream" data-dfn-type="dfn" data-noexport id="textdecoderstream-stream">stream</dfn>. </p>
   <dl class="domintro">
    <dt><code><var>decoder</var> = new <a class="idl-code" data-link-type="constructor" href="#dom-textdecoderstream" id="ref-for-dom-textdecoderstream①">TextDecoderStream([<var>label</var> =
 "utf-8" [, <var>options</var>]])</a></code> 
    <dd>
     <p>Returns a new <code class="idl"><a data-link-type="idl" href="#textdecoderstream" id="ref-for-textdecoderstream⑤">TextDecoderStream</a></code> object. </p>
     <p>If <var>label</var> is either not a <a data-link-type="dfn" href="#label" id="ref-for-label①②">label</a> or is a <a data-link-type="dfn" href="#label" id="ref-for-label①③">label</a> for <a data-link-type="dfn" href="#replacement" id="ref-for-replacement⑦">replacement</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw" id="ref-for-dfn-throw④">throws</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-rangeerror" id="ref-for-exceptiondef-rangeerror②">RangeError</a></code>. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textdecoder-encoding" id="ref-for-dom-textdecoder-encoding②">encoding</a></code> 
    <dd>
     <p>Returns <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding⑦">encoding</a>’s <a data-link-type="dfn" href="#name" id="ref-for-name⑤">name</a>, lowercased. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textdecoder-fatal" id="ref-for-dom-textdecoder-fatal②">fatal</a></code> 
    <dd>
     <p>Returns true if <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode⑤">error mode</a> is "<code>fatal</code>", and
 false otherwise. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textdecoder-ignorebom" id="ref-for-dom-textdecoder-ignorebom②">ignoreBOM</a></code> 
    <dd>
     <p>Returns true if <a data-link-type="dfn" href="#textdecoder-ignore-bom-flag" id="ref-for-textdecoder-ignore-bom-flag④">ignore BOM flag</a> is set, and false
 otherwise. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-generictransformstream-readable" id="ref-for-dom-generictransformstream-readable①">readable</a></code> 
    <dd>
     <p>Returns a <a data-link-type="dfn" href="https://streams.spec.whatwg.org/#readable-stream" id="ref-for-readable-stream">readable stream</a> whose <a data-link-type="dfn" href="https://streams.spec.whatwg.org/#chunk" id="ref-for-chunk">chunks</a> are strings resulting from running <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding⑧">encoding</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①④">decoder</a> on the chunks written to <code class="idl"><a data-link-type="idl" href="#dom-generictransformstream-writable" id="ref-for-dom-generictransformstream-writable①">writable</a></code>. </p>
    <dt><code><var>decoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-generictransformstream-writable" id="ref-for-dom-generictransformstream-writable②">writable</a></code> 
    <dd>
     <p>Returns a <a data-link-type="dfn" href="https://streams.spec.whatwg.org/#writable-stream" id="ref-for-writable-stream">writable stream</a> which accepts <code>[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#AllowShared" id="ref-for-AllowShared②">AllowShared</a>] <a class="idl-code" data-link-type="typedef" href="https://heycam.github.io/webidl/#BufferSource" id="ref-for-BufferSource①">BufferSource</a></code> chunks and runs
  them through <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding⑨">encoding</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①⑤">decoder</a> before making them
  available to <code class="idl"><a data-link-type="idl" href="#dom-generictransformstream-readable" id="ref-for-dom-generictransformstream-readable②">readable</a></code>. </p>
     <p>Typically this will be used via the <code class="idl"><a data-link-type="idl" href="https://streams.spec.whatwg.org/#rs-pipe-through" id="ref-for-rs-pipe-through">pipeThrough()</a></code> method on a <code class="idl"><a data-link-type="idl" href="https://streams.spec.whatwg.org/#rs-class" id="ref-for-rs-class①">ReadableStream</a></code> source. </p>
<pre class="example" id="example-textdecoderstream-writable"><a class="self-link" href="#example-textdecoderstream-writable"></a><code class="lang-javascript highlight"><c- a>var</c-> decoder <c- o>=</c-> <c- k>new</c-> TextDecoderStream<c- p>(</c->encoding<c- p>);</c->
byteReadable
  <c- p>.</c->pipeThrough<c- p>(</c->decoder<c- p>)</c->
  <c- p>.</c->pipeTo<c- p>(</c->textWritable<c- p>);</c-></code></pre>
     <p>If the <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode⑥">error mode</a> is "<code>fatal</code>" and <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding①⓪">encoding</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①⑥">decoder</a> returns <a data-link-type="dfn" href="#error" id="ref-for-error⑧">error</a>, both <code class="idl"><a data-link-type="idl" href="#dom-generictransformstream-readable" id="ref-for-dom-generictransformstream-readable③">readable</a></code> and <code class="idl"><a data-link-type="idl" href="#dom-generictransformstream-writable" id="ref-for-dom-generictransformstream-writable③">writable</a></code> will be errored with a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror②">TypeError</a></code>. </p>
   </dl>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextDecoderStream" data-dfn-type="constructor" data-export data-lt="TextDecoderStream(label, options)|constructor(label, options)|TextDecoderStream(label)|constructor(label)|TextDecoderStream()|constructor()" id="dom-textdecoderstream"><code>TextDecoderStream(<var>label</var>, <var>options</var>)</code></dfn> constructor, when invoked, must run these steps: </p>
   <ol>
    <li>
     <p>Let <var>encoding</var> be the result of <a data-link-type="dfn" href="#concept-encoding-get" id="ref-for-concept-encoding-get②">getting an encoding</a> from <var>label</var>. </p>
    <li>
     <p>If <var>encoding</var> is failure or <a data-link-type="dfn" href="#replacement" id="ref-for-replacement⑧">replacement</a>, then <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw" id="ref-for-dfn-throw⑤">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-rangeerror" id="ref-for-exceptiondef-rangeerror③">RangeError</a></code>. </p>
    <li>
     <p>Let <var>dec</var> be a new <code class="idl"><a data-link-type="idl" href="#textdecoderstream" id="ref-for-textdecoderstream⑥">TextDecoderStream</a></code> object. </p>
    <li>
     <p>Set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding①①">encoding</a> to <var>encoding</var>. </p>
    <li>
     <p>If <var>options</var>’s <code>fatal</code> member is true, then set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode⑦">error mode</a> to "<code>fatal</code>". </p>
    <li>
     <p>If <var>options</var>’s <code>ignoreBOM</code> member is true, then set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-ignore-bom-flag" id="ref-for-textdecoder-ignore-bom-flag⑤">ignore BOM flag</a>. </p>
    <li>
     <p>Set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-decoder" id="ref-for-textdecoderstream-decoder">decoder</a> to a new <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①⑦">decoder</a> for <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-encoding" id="ref-for-textdecoder-encoding①②">encoding</a>, and set <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-stream" id="ref-for-textdecoderstream-stream">stream</a> to a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream②⓪">stream</a>. </p>
    <li>
     <p>Let <var>startAlgorithm</var> be an algorithm that takes no arguments and returns nothing. </p>
    <li>
     <p>Let <var>transformAlgorithm</var> be an algorithm which takes a <var>chunk</var> argument
 and runs the <a data-link-type="dfn" href="#decode-and-enqueue-a-chunk" id="ref-for-decode-and-enqueue-a-chunk">decode and enqueue a chunk</a> algorithm with <var>dec</var> and <var>chunk</var>. </p>
    <li>
     <p>Let <var>flushAlgorithm</var> be an algorithm which takes no arguments and runs the <a data-link-type="dfn" href="#flush-and-enqueue" id="ref-for-flush-and-enqueue">flush
 and enqueue</a> algorithm with <var>dec</var>. </p>
    <li>
     <p>Let <var>transform</var> be the result of calling <a data-link-type="abstract-op" href="https://streams.spec.whatwg.org/#create-transform-stream" id="ref-for-create-transform-stream">CreateTransformStream</a>(<var>startAlgorithm</var>, <var>transformAlgorithm</var>, <var>flushAlgorithm</var>). </p>
    <li>
     <p>Set <var>dec</var>’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform②">transform</a> to <var>transform</var>. </p>
    <li>
     <p>Return <var>dec</var>. </p>
   </ol>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="decode-and-enqueue-a-chunk">decode and enqueue a chunk</dfn> algorithm, given a <code class="idl"><a data-link-type="idl" href="#textdecoderstream" id="ref-for-textdecoderstream⑦">TextDecoderStream</a></code> object <var>dec</var> and a <var>chunk</var>, runs these steps: </p>
   <ol>
    <li>
     <p>Let <var>bufferSource</var> be the result of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-convert-ecmascript-to-idl-value" id="ref-for-dfn-convert-ecmascript-to-idl-value">converting</a> <var>chunk</var> to an <code>[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#AllowShared" id="ref-for-AllowShared③">AllowShared</a>] <a class="idl-code" data-link-type="typedef" href="https://heycam.github.io/webidl/#BufferSource" id="ref-for-BufferSource②">BufferSource</a></code>. If this throws an
 exception, then return a promise rejected with that exception. </p>
    <li>
     <p><a data-link-type="dfn" href="#concept-stream-push" id="ref-for-concept-stream-push③">Push</a> a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-get-buffer-source-copy" id="ref-for-dfn-get-buffer-source-copy①">copy of</a> <var>bufferSource</var> to <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-stream" id="ref-for-textdecoderstream-stream①">stream</a>. If this throws an exception, then return a
  promise rejected with that exception. </p>
     <p class="warning">See the <a href="#sharedarraybuffer-warning">warning for <code>SharedArrayBuffer</code> objects</a> above. </p>
    <li>
     <p>Let <var>controller</var> be <var>dec</var>’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform③">transform</a>.[[transformStreamController]]. </p>
    <li>
     <p>Let <var>output</var> be a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream②①">stream</a>. </p>
    <li>
     <p>While true, run these steps: </p>
     <ol>
      <li>
       <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read⑧">reading</a> from <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-stream" id="ref-for-textdecoderstream-stream②">stream</a>. </p>
      <li>
       <p>If <var>token</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream⑥">end-of-stream</a>, run these steps: </p>
       <ol>
        <li>
         <p>Let <var>outputChunk</var> be <var>output</var>, <a data-link-type="dfn" href="#concept-td-serialize" id="ref-for-concept-td-serialize②">serialized</a>. </p>
        <li>
         <p>if <var>outputChunk</var> is non-empty, call <a data-link-type="abstract-op" href="https://streams.spec.whatwg.org/#transform-stream-default-controller-enqueue" id="ref-for-transform-stream-default-controller-enqueue">TransformStreamDefaultControllerEnqueue</a>(<var>controller</var>, <var>outputChunk</var>). </p>
        <li>
         <p>Return a new promise resolved with undefined. </p>
       </ol>
      <li>
       <p>Let <var>result</var> be the result of <a data-link-type="dfn" href="#concept-encoding-process" id="ref-for-concept-encoding-process③">processing</a> <var>token</var> for <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-decoder" id="ref-for-textdecoderstream-decoder①">decoder</a>, <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-stream" id="ref-for-textdecoderstream-stream③">stream</a>, <var>output</var>, and <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode⑧">error mode</a>. </p>
      <li>
       <p>If <var>result</var> is <a data-link-type="dfn" href="#error" id="ref-for-error⑨">error</a>, then return a new promise rejected with a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror③">TypeError</a></code> exception. </p>
     </ol>
   </ol>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="flush-and-enqueue">flush and enqueue</dfn> algorithm, which handles the end of data from the input <code class="idl"><a data-link-type="idl" href="https://streams.spec.whatwg.org/#rs-class" id="ref-for-rs-class②">ReadableStream</a></code> object, given a <code class="idl"><a data-link-type="idl" href="#textdecoderstream" id="ref-for-textdecoderstream⑧">TextDecoderStream</a></code> object <var>dec</var>, runs these steps: </p>
   <ol>
    <li>
     <p>Let <var>output</var> be a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream②②">stream</a>. </p>
    <li>
     <p>Let <var>result</var> be the result of <a data-link-type="dfn" href="#concept-encoding-process" id="ref-for-concept-encoding-process④">processing</a> <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream⑦">end-of-stream</a> for <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-decoder" id="ref-for-textdecoderstream-decoder②">decoder</a> and <var>dec</var>’s <a data-link-type="dfn" href="#textdecoderstream-stream" id="ref-for-textdecoderstream-stream④">stream</a>, <var>output</var>, and <var>dec</var>’s <a data-link-type="dfn" href="#textdecoder-error-mode" id="ref-for-textdecoder-error-mode⑨">error mode</a>. </p>
    <li>
     <p>If <var>result</var> is <a data-link-type="dfn" href="#finished" id="ref-for-finished④">finished</a>, run these steps: </p>
     <ol>
      <li>
       <p>Let <var>outputChunk</var> be <var>output</var>, <a data-link-type="dfn" href="#concept-td-serialize" id="ref-for-concept-td-serialize③">serialized</a>. </p>
      <li>
       <p>Let <var>controller</var> be <var>dec</var>’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform④">transform</a>.[[transformStreamController]]. </p>
      <li>
       <p>If <var>outputChunk</var> is non-empty, call <a data-link-type="abstract-op" href="https://streams.spec.whatwg.org/#transform-stream-default-controller-enqueue" id="ref-for-transform-stream-default-controller-enqueue①">TransformStreamDefaultControllerEnqueue</a>(<var>controller</var>, <var>outputChunk</var>). </p>
      <li>
       <p>Return a new promise resolved with undefined. </p>
     </ol>
    <li>
     <p>Otherwise, return a new promise rejected with a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#exceptiondef-typeerror" id="ref-for-exceptiondef-typeerror④">TypeError</a></code> exception. </p>
   </ol>
   <h3 class="heading settled" data-level="7.7" id="interface-textencoderstream"><span class="secno">7.7. </span><span class="content">Interface <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream①">TextEncoderStream</a></code></span><a class="self-link" href="#interface-textencoderstream"></a></h3>
<pre class="idl highlight def">[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed③"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="textencoderstream"><code><c- g>TextEncoderStream</c-></code></dfn> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textencoderstream" id="ref-for-dom-textencoderstream"><c- g>constructor</c-></a>();
};
<a class="n" data-link-type="idl-name" href="#textencoderstream" id="ref-for-textencoderstream②"><c- n>TextEncoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textencodercommon" id="ref-for-textencodercommon③"><c- n>TextEncoderCommon</c-></a>;
<a class="n" data-link-type="idl-name" href="#textencoderstream" id="ref-for-textencoderstream③"><c- n>TextEncoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#generictransformstream" id="ref-for-generictransformstream④"><c- n>GenericTransformStream</c-></a>;
</pre>
   <p>A <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream④">TextEncoderStream</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-for="TextEncoderStream" data-dfn-type="dfn" data-noexport id="textencoderstream-encoder">encoder</dfn>,
and <dfn class="dfn-paneled" data-dfn-for="TextEncoderStream" data-dfn-type="dfn" data-noexport id="textencoderstream-pending-high-surrogate">pending high surrogate</dfn> (initially null). </p>
   <p class="note no-backref" role="note">A <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream⑤">TextEncoderStream</a></code> object offers no <var>label</var> argument as it
only supports <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①⑧">UTF-8</a>. </p>
   <dl class="domintro">
    <dt><code><var>encoder</var> = new <a class="idl-code" data-link-type="constructor" href="#dom-textencoderstream" id="ref-for-dom-textencoderstream①">TextEncoderStream()</a></code> 
    <dd>
     <p>Returns a new <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream⑥">TextEncoderStream</a></code> object. </p>
    <dt><code><var>encoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-textencoder-encoding" id="ref-for-dom-textencoder-encoding②">encoding</a></code> 
    <dd>
     <p>Returns "<code>utf-8</code>". </p>
    <dt><code><var>encoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-generictransformstream-readable" id="ref-for-dom-generictransformstream-readable④">readable</a></code> 
    <dd>
     <p>Returns a <a data-link-type="dfn" href="https://streams.spec.whatwg.org/#readable-stream" id="ref-for-readable-stream①">readable stream</a> whose <a data-link-type="dfn" href="https://streams.spec.whatwg.org/#chunk" id="ref-for-chunk①">chunks</a> are <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array④">Uint8Array</a></code>s resulting from running <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8①⑨">UTF-8</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①⓪">encoder</a> on the chunks written to <code class="idl"><a data-link-type="idl" href="#dom-generictransformstream-writable" id="ref-for-dom-generictransformstream-writable④">writable</a></code>. </p>
    <dt><code><var>encoder</var> . <a class="idl-code" data-link-type="attribute" href="#dom-generictransformstream-writable" id="ref-for-dom-generictransformstream-writable⑤">writable</a></code> 
    <dd>
     <p>Returns a <a data-link-type="dfn" href="https://streams.spec.whatwg.org/#writable-stream" id="ref-for-writable-stream①">writable stream</a> which accepts string chunks and runs them through <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8②⓪">UTF-8</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①①">encoder</a> before making them available to <code class="idl"><a data-link-type="idl" href="#dom-generictransformstream-readable" id="ref-for-dom-generictransformstream-readable⑤">readable</a></code>. </p>
     <p>Typically this will be used via the <code class="idl"><a data-link-type="idl" href="https://streams.spec.whatwg.org/#rs-pipe-through" id="ref-for-rs-pipe-through①">pipeThrough()</a></code> method on a <code class="idl"><a data-link-type="idl" href="https://streams.spec.whatwg.org/#rs-class" id="ref-for-rs-class③">ReadableStream</a></code> source. </p>
<pre class="example" id="example-textencoderstream-writable"><a class="self-link" href="#example-textencoderstream-writable"></a><code class="lang-javascript highlight">textReadable
  <c- p>.</c->pipeThrough<c- p>(</c-><c- k>new</c-> TextEncoderStream<c- p>())</c->
  <c- p>.</c->pipeTo<c- p>(</c->byteWritable<c- p>);</c-></code></pre>
   </dl>
   <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="TextEncoderStream" data-dfn-type="constructor" data-export data-lt="TextEncoderStream()|constructor()" id="dom-textencoderstream"><code>TextEncoderStream()</code></dfn> constructor, when invoked, must run these steps: </p>
   <ol>
    <li>
     <p>Let <var>enc</var> be a new <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream⑦">TextEncoderStream</a></code> object. </p>
    <li>
     <p>Set <var>enc</var>’s <a data-link-type="dfn" href="#textencoderstream-encoder" id="ref-for-textencoderstream-encoder">encoder</a> to <a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8②①">UTF-8</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①②">encoder</a>. </p>
    <li>
     <p>Let <var>startAlgorithm</var> be an algorithm that takes no arguments and returns nothing. </p>
    <li>
     <p>Let <var>transformAlgorithm</var> be an algorithm which takes a <var>chunk</var> argument
 and runs the <a data-link-type="dfn" href="#encode-and-enqueue-a-chunk" id="ref-for-encode-and-enqueue-a-chunk">encode and enqueue a chunk</a> algorithm with <var>enc</var> and <var>chunk</var>. </p>
    <li>
     <p>Let <var>flushAlgorithm</var> be an algorithm which runs the <a data-link-type="dfn" href="#encode-and-flush" id="ref-for-encode-and-flush">encode and flush</a> algorithm with <var>enc</var>. </p>
    <li>
     <p>Let <var>transform</var> be the result of calling <a data-link-type="abstract-op" href="https://streams.spec.whatwg.org/#create-transform-stream" id="ref-for-create-transform-stream①">CreateTransformStream</a>(<var>startAlgorithm</var>, <var>transformAlgorithm</var>, <var>flushAlgorithm</var>). </p>
    <li>
     <p>Set <var>enc</var>’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform⑤">transform</a> to <var>transform</var>. </p>
    <li>
     <p>Return <var>enc</var>. </p>
   </ol>
   <hr>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="encode-and-enqueue-a-chunk">encode and enqueue a chunk</dfn> algorithm, given a <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream⑧">TextEncoderStream</a></code> object <var>enc</var> and <var>chunk</var>, runs these steps: </p>
   <ol>
    <li>
     <p>Let <var>input</var> be the result of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-convert-ecmascript-to-idl-value" id="ref-for-dfn-convert-ecmascript-to-idl-value①">converting</a> <var>chunk</var> to a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString④">DOMString</a></code>. If this throws an exception, then return a promise rejected
 with that exception. </p>
     <p class="note" role="note"><code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString⑤">DOMString</a></code> is used here so that a surrogate pair that is split between chunks can
 be reassembled into the appropriate scalar value. The behavior is otherwise identical to <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-USVString" id="ref-for-idl-USVString③">USVString</a></code>. In particular, lone surrogates will be replaced with U+FFFD. </p>
    <li>
     <p>Convert <var>input</var> to a <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream②③">stream</a>. </p>
    <li>
     <p>Let <var>output</var> be a new <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream②④">stream</a>. </p>
    <li>
     <p>Let <var>controller</var> be <var>enc</var>’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform⑥">transform</a>.[[transformStreamController]]. </p>
    <li>
     <p>While true, run these steps: </p>
     <ol>
      <li>
       <p>Let <var>token</var> be the result of <a data-link-type="dfn" href="#concept-stream-read" id="ref-for-concept-stream-read⑨">reading</a> from <var>input</var>. </p>
      <li>
       <p>If <var>token</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream⑧">end-of-stream</a>, run these steps: </p>
       <ol>
        <li>
         <p>Convert <var>output</var> into a byte sequence. </p>
        <li>
         <p>If <var>output</var> is non-empty, run these steps: </p>
         <ol>
          <li>
           <p>Let <var>chunk</var> be a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array⑤">Uint8Array</a></code> object wrapping an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-ArrayBuffer" id="ref-for-idl-ArrayBuffer④">ArrayBuffer</a></code> containing <var>output</var>. </p>
          <li>
           <p>Call <a data-link-type="abstract-op" href="https://streams.spec.whatwg.org/#transform-stream-default-controller-enqueue" id="ref-for-transform-stream-default-controller-enqueue②">TransformStreamDefaultControllerEnqueue</a>(<var>controller</var>, <var>chunk</var>). </p>
         </ol>
        <li>
         <p>Return a new promise resolved with undefined. </p>
       </ol>
      <li>
       <p>Let <var>result</var> be the result of executing the <a data-link-type="dfn" href="#convert-code-unit-to-scalar-value" id="ref-for-convert-code-unit-to-scalar-value">convert code unit to scalar
   value</a> algorithm with <var>enc</var>, <var>token</var> and <var>input</var>. </p>
      <li>
       <p>If <var>result</var> is not <a data-link-type="dfn" href="#continue" id="ref-for-continue③">continue</a>, then <a data-link-type="dfn" href="#concept-encoding-process" id="ref-for-concept-encoding-process⑤">process</a> <var>result</var> for <a data-link-type="dfn" href="#textencoderstream-encoder" id="ref-for-textencoderstream-encoder①">encoder</a>, <var>input</var>, <var>output</var>. </p>
     </ol>
   </ol>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="convert-code-unit-to-scalar-value">convert code unit to scalar value</dfn> algorithm, given a <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream⑨">TextEncoderStream</a></code> object <var>enc</var>, <var>token</var>, and stream <var>input</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>enc</var>’s <a data-link-type="dfn" href="#textencoderstream-pending-high-surrogate" id="ref-for-textencoderstream-pending-high-surrogate">pending high surrogate</a> is non-null, run these steps: </p>
     <ol>
      <li>
       <p>Let <var>high surrogate</var> be <var>enc</var>’s <a data-link-type="dfn" href="#textencoderstream-pending-high-surrogate" id="ref-for-textencoderstream-pending-high-surrogate①">pending high surrogate</a>. </p>
      <li>
       <p>Set <var>enc</var>’s <a data-link-type="dfn" href="#textencoderstream-pending-high-surrogate" id="ref-for-textencoderstream-pending-high-surrogate②">pending high surrogate</a> to null. </p>
      <li>
       <p>If <var>token</var> is in the range U+DC00 to U+DFFF, inclusive, then return a code point
   whose value is 0x10000 + ((<var>high surrogate</var> − 0xD800) &lt;&lt; 10) +
   (<var>token</var> − 0xDC00). </p>
      <li>
       <p><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend④">Prepend</a> <var>token</var> to <var>input</var>. </p>
      <li>
       <p>Return U+FFFD. </p>
     </ol>
    <li>
     <p>If <var>token</var> is in the range U+D800 to U+DBFF, inclusive, then set <a data-link-type="dfn" href="#textencoderstream-pending-high-surrogate" id="ref-for-textencoderstream-pending-high-surrogate③">pending high
 surrogate</a> to <var>token</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue④">continue</a>. </p>
    <li>
     <p>If <var>token</var> is in the range U+DC00 to U+DFFF, inclusive, then return U+FFFD. </p>
    <li>
     <p>Return <var>token</var>. </p>
   </ol>
   <p class="note" role="note">This is equivalent to the "<a data-link-type="dfn" href="https://infra.spec.whatwg.org/#javascript-string-convert" id="ref-for-javascript-string-convert">convert</a> a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#javascript-string" id="ref-for-javascript-string">JavaScript string</a> into a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#scalar-value-string" id="ref-for-scalar-value-string">scalar
value string</a>" algorithm from the Infra Standard, but allows for surrogate pairs that are split
between strings. <a data-link-type="biblio" href="#biblio-infra">[INFRA]</a> </p>
   <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="encode-and-flush">encode and flush</dfn> algorithm, given a <code class="idl"><a data-link-type="idl" href="#textencoderstream" id="ref-for-textencoderstream①⓪">TextEncoderStream</a></code> object <var>enc</var>,
runs these steps: </p>
   <ol>
    <li>
     <p>If <var>enc</var>’s <a data-link-type="dfn" href="#textencoderstream-pending-high-surrogate" id="ref-for-textencoderstream-pending-high-surrogate④">pending high surrogate</a> is non-null, run these steps: </p>
     <ol>
      <li>
       <p>Let <var>controller</var> be <var>enc</var>’s <a data-link-type="dfn" href="#generictransformstream-transform" id="ref-for-generictransformstream-transform⑦">transform</a>.[[transformStreamController]]. </p>
      <li>
       <p>Let <var>output</var> be the byte sequence 0xEF 0xBF 0xBD. </p>
       <p class="note" role="note">This is the replacement character U+FFFD encoded as UTF-8. </p>
      <li>
       <p>Let <var>chunk</var> be a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array⑥">Uint8Array</a></code> object wrapping an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#idl-ArrayBuffer" id="ref-for-idl-ArrayBuffer⑤">ArrayBuffer</a></code> containing <var>output</var>. </p>
      <li>
       <p>Call <a data-link-type="abstract-op" href="https://streams.spec.whatwg.org/#transform-stream-default-controller-enqueue" id="ref-for-transform-stream-default-controller-enqueue③">TransformStreamDefaultControllerEnqueue</a>(<var>controller</var>, <var>chunk</var>). </p>
     </ol>
    <li>
     <p>Return a new promise resolved with undefined. </p>
   </ol>
   <h2 class="heading settled" data-level="8" id="the-encoding"><span class="secno">8. </span><span class="content">The encoding</span><a class="self-link" href="#the-encoding"></a></h2>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="8.1" data-lt="UTF-8" id="utf-8"><span class="secno">8.1. </span><span class="content">UTF-8</span></h3>
   <h4 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="8.1.1" data-lt="UTF-8 decoder" id="utf-8-decoder"><span class="secno">8.1.1. </span><span class="content">UTF-8 decoder</span></h4>
   <p class="note no-backref" role="note">A byte order mark has priority over a <a data-link-type="dfn" href="#label" id="ref-for-label①④">label</a> as it has been found
to be more accurate in deployed content. Therefore it is not part of the <a data-link-type="dfn" href="#utf-8-decoder" id="ref-for-utf-8-decoder">UTF-8 decoder</a> algorithm but rather the <a data-link-type="dfn" href="#decode" id="ref-for-decode③">decode</a> and <a data-link-type="dfn" href="#utf-8-decode" id="ref-for-utf-8-decode③">UTF-8 decode</a> algorithms. </p>
   <p><a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8②②">UTF-8</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①⑧">decoder</a>’s has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-8-code-point">UTF-8 code point</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-8-bytes-seen">UTF-8 bytes seen</dfn>, and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-8-bytes-needed">UTF-8 bytes needed</dfn> (all initially 0), a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-8-lower-boundary">UTF-8 lower boundary</dfn> (initially 0x80), and a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-8-upper-boundary">UTF-8 upper boundary</dfn> (initially 0xBF). </p>
   <p><a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8②③">UTF-8</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder①⑨">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler④">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream⑨">end-of-stream</a> and <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed">UTF-8 bytes needed</a> is not 0, set <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed①">UTF-8 bytes needed</a> to 0 and return <a data-link-type="dfn" href="#error" id="ref-for-error①⓪">error</a>. </p>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①⓪">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished⑤">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed②">UTF-8 bytes needed</a> is 0, based on <var>byte</var>: </p>
     <dl class="switch">
      <dt>0x00 to 0x7F 
      <dd>
       <p>Return a code point whose value is <var>byte</var>. </p>
      <dt>0xC2 to 0xDF 
      <dd>
       <ol>
        <li>
         <p>Set <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed③">UTF-8 bytes needed</a> to 1. </p>
        <li>
         <p>Set <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point">UTF-8 code point</a> to <var>byte</var> &amp; 0x1F. </p>
         <p class="note" role="note">The five least significant bits of <var>byte</var>. </p>
       </ol>
      <dt>0xE0 to 0xEF 
      <dd>
       <ol>
        <li>
         <p>If <var>byte</var> is 0xE0, set <a data-link-type="dfn" href="#utf-8-lower-boundary" id="ref-for-utf-8-lower-boundary">UTF-8 lower boundary</a> to 0xA0. </p>
        <li>
         <p>If <var>byte</var> is 0xED, set <a data-link-type="dfn" href="#utf-8-upper-boundary" id="ref-for-utf-8-upper-boundary">UTF-8 upper boundary</a> to 0x9F. </p>
        <li>
         <p>Set <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed④">UTF-8 bytes needed</a> to 2. </p>
        <li>
         <p>Set <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point①">UTF-8 code point</a> to <var>byte</var> &amp; 0xF. </p>
         <p class="note" role="note">The four least significant bits of <var>byte</var>. </p>
       </ol>
      <dt>0xF0 to 0xF4 
      <dd>
       <ol>
        <li>
         <p>If <var>byte</var> is 0xF0, set <a data-link-type="dfn" href="#utf-8-lower-boundary" id="ref-for-utf-8-lower-boundary①">UTF-8 lower boundary</a> to 0x90. </p>
        <li>
         <p>If <var>byte</var> is 0xF4, set <a data-link-type="dfn" href="#utf-8-upper-boundary" id="ref-for-utf-8-upper-boundary①">UTF-8 upper boundary</a> to 0x8F. </p>
        <li>
         <p>Set <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed⑤">UTF-8 bytes needed</a> to 3. </p>
        <li>
         <p>Set <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point②">UTF-8 code point</a> to <var>byte</var> &amp; 0x7. </p>
         <p class="note" role="note">The three least significant bits of <var>byte</var>. </p>
       </ol>
      <dt>Otherwise 
      <dd>
       <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error①①">error</a>. </p>
     </dl>
     <p>Return <a data-link-type="dfn" href="#continue" id="ref-for-continue⑤">continue</a>. </p>
    <li>
     <p>If <var>byte</var> is not in the range <a data-link-type="dfn" href="#utf-8-lower-boundary" id="ref-for-utf-8-lower-boundary②">UTF-8 lower boundary</a> to <a data-link-type="dfn" href="#utf-8-upper-boundary" id="ref-for-utf-8-upper-boundary②">UTF-8 upper boundary</a>, inclusive, then: </p>
     <ol>
      <li>
       <p>Set <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point③">UTF-8 code point</a>, <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed⑥">UTF-8 bytes needed</a>, and <a data-link-type="dfn" href="#utf-8-bytes-seen" id="ref-for-utf-8-bytes-seen">UTF-8 bytes seen</a> to 0,
   set <a data-link-type="dfn" href="#utf-8-lower-boundary" id="ref-for-utf-8-lower-boundary③">UTF-8 lower boundary</a> to 0x80, and set <a data-link-type="dfn" href="#utf-8-upper-boundary" id="ref-for-utf-8-upper-boundary③">UTF-8 upper boundary</a> to 0xBF. </p>
      <li>
       <p><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend⑤">Prepend</a> <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error①②">error</a>. </p>
     </ol>
    <li>
     <p>Set <a data-link-type="dfn" href="#utf-8-lower-boundary" id="ref-for-utf-8-lower-boundary④">UTF-8 lower boundary</a> to 0x80 and <a data-link-type="dfn" href="#utf-8-upper-boundary" id="ref-for-utf-8-upper-boundary④">UTF-8 upper boundary</a> to 0xBF. </p>
    <li>
     <p>Set <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point④">UTF-8 code point</a> to (<a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point⑤">UTF-8 code point</a> &lt;&lt; 6) |
  (<var>byte</var> &amp; 0x3F) </p>
     <p class="note no-backref" role="note">Shift the existing bits of <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point⑥">UTF-8 code point</a> left by six
  places and set the newly-vacated six least significant bits to the six least significant bits of <var>byte</var>. </p>
    <li>
     <p>Increase <a data-link-type="dfn" href="#utf-8-bytes-seen" id="ref-for-utf-8-bytes-seen①">UTF-8 bytes seen</a> by one. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#utf-8-bytes-seen" id="ref-for-utf-8-bytes-seen②">UTF-8 bytes seen</a> is not equal to <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed⑦">UTF-8 bytes needed</a>, return <a data-link-type="dfn" href="#continue" id="ref-for-continue⑥">continue</a>. </p>
    <li>
     <p>Let <var>code point</var> be <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point⑦">UTF-8 code point</a>. </p>
    <li>
     <p>Set <a data-link-type="dfn" href="#utf-8-code-point" id="ref-for-utf-8-code-point⑧">UTF-8 code point</a>, <a data-link-type="dfn" href="#utf-8-bytes-needed" id="ref-for-utf-8-bytes-needed⑧">UTF-8 bytes needed</a>, and <a data-link-type="dfn" href="#utf-8-bytes-seen" id="ref-for-utf-8-bytes-seen③">UTF-8 bytes seen</a> to 0. </p>
    <li>
     <p>Return a code point whose value is <var>code point</var>. </p>
   </ol>
   <p class="note" role="note">The constraints in the <a data-link-type="dfn" href="#utf-8-decoder" id="ref-for-utf-8-decoder①">UTF-8 decoder</a> above match
“Best Practices for Using U+FFFD” from the Unicode standard. No other
behavior is permitted per the Encoding Standard (other algorithms that
achieve the same result are fine, even encouraged). <a data-link-type="biblio" href="#biblio-unicode">[UNICODE]</a> </p>
   <h4 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="8.1.2" data-lt="UTF-8 encoder" id="utf-8-encoder"><span class="secno">8.1.2. </span><span class="content">UTF-8 encoder</span></h4>
   <p><a data-link-type="dfn" href="#utf-8" id="ref-for-utf-8②④">UTF-8</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①③">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler⑤">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①①">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished⑥">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point①">ASCII code point</a>, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>Set <var>count</var> and <var>offset</var> based on the
  range <var>code point</var> is in: </p>
     <dl class="switch">
      <dt>U+0080 to U+07FF, inclusive 
      <dd>1 and 0xC0 
      <dt>U+0800 to U+FFFF, inclusive 
      <dd>2 and 0xE0 
      <dt>U+10000 to U+10FFFF, inclusive 
      <dd>3 and 0xF0 
     </dl>
    <li>
     <p>Let <var>bytes</var> be a byte sequence whose first byte is
 (<var>code point</var> >> (6 × <var>count</var>)) + <var>offset</var>. </p>
    <li>
     <p>While <var>count</var> is greater than 0: </p>
     <ol>
      <li>
       <p>Set <var>temp</var> to <var>code point</var> >> (6 × (<var>count</var> − 1)). </p>
      <li>
       <p>Append to <var>bytes</var> 0x80 | (<var>temp</var> &amp; 0x3F). </p>
      <li>
       <p>Decrease <var>count</var> by one. </p>
     </ol>
    <li>
     <p>Return bytes <var>bytes</var>, in order. </p>
   </ol>
   <p class="note" role="note">This algorithm has identical results to the one described in the Unicode standard. It
is included here for completeness. <a data-link-type="biblio" href="#biblio-unicode">[UNICODE]</a> </p>
   <h2 class="heading settled" data-level="9" id="legacy-single-byte-encodings"><span class="secno">9. </span><span class="content">Legacy single-byte encodings</span><a class="self-link" href="#legacy-single-byte-encodings"></a></h2>
   <p>An <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②②">encoding</a> where each byte is either a single code point or
nothing, is a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="single-byte-encoding">single-byte encoding</dfn>. <a data-link-type="dfn" href="#single-byte-encoding" id="ref-for-single-byte-encoding">Single-byte encodings</a> share the <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②⓪">decoder</a> and <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①④">encoder</a>. <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="index-single-byte">Index single-byte</dfn>,
as referenced by the <a data-link-type="dfn" href="#single-byte-decoder" id="ref-for-single-byte-decoder">single-byte decoder</a> and <a data-link-type="dfn" href="#single-byte-encoder" id="ref-for-single-byte-encoder">single-byte encoder</a>,  is defined by the following table, and
depends on the <a data-link-type="dfn" href="#single-byte-encoding" id="ref-for-single-byte-encoding①">single-byte encoding</a> in use. All but two <a data-link-type="dfn" href="#single-byte-encoding" id="ref-for-single-byte-encoding②">single-byte encodings</a> have a
unique <a data-link-type="dfn" href="#index" id="ref-for-index①①">index</a>. </p>
   <table>
    <tbody>
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="ibm866">IBM866</dfn>
      <td><a href="index-ibm866.txt">index-ibm866.txt</a>
      <td><a href="ibm866.html">index IBM866 visualization</a>
      <td><a href="ibm866-bmp.html">index IBM866 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-2">ISO-8859-2</dfn>
      <td><a href="index-iso-8859-2.txt">index-iso-8859-2.txt</a>
      <td><a href="iso-8859-2.html">index ISO-8859-2 visualization</a>
      <td><a href="iso-8859-2-bmp.html">index ISO-8859-2 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-3">ISO-8859-3</dfn>
      <td><a href="index-iso-8859-3.txt">index-iso-8859-3.txt</a>
      <td><a href="iso-8859-3.html">index ISO-8859-3 visualization</a>
      <td><a href="iso-8859-3-bmp.html">index ISO-8859-3 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-4">ISO-8859-4</dfn>
      <td><a href="index-iso-8859-4.txt">index-iso-8859-4.txt</a>
      <td><a href="iso-8859-4.html">index ISO-8859-4 visualization</a>
      <td><a href="iso-8859-4-bmp.html">index ISO-8859-4 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-5">ISO-8859-5</dfn>
      <td><a href="index-iso-8859-5.txt">index-iso-8859-5.txt</a>
      <td><a href="iso-8859-5.html">index ISO-8859-5 visualization</a>
      <td><a href="iso-8859-5-bmp.html">index ISO-8859-5 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-6">ISO-8859-6</dfn>
      <td><a href="index-iso-8859-6.txt">index-iso-8859-6.txt</a>
      <td><a href="iso-8859-6.html">index ISO-8859-6 visualization</a>
      <td><a href="iso-8859-6-bmp.html">index ISO-8859-6 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-7">ISO-8859-7</dfn>
      <td><a href="index-iso-8859-7.txt">index-iso-8859-7.txt</a>
      <td><a href="iso-8859-7.html">index ISO-8859-7 visualization</a>
      <td><a href="iso-8859-7-bmp.html">index ISO-8859-7 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-8">ISO-8859-8</dfn>
      <td rowspan="2"><a href="index-iso-8859-8.txt">index-iso-8859-8.txt</a>
      <td rowspan="2"><a href="iso-8859-8.html">index ISO-8859-8 visualization</a>
      <td rowspan="2"><a href="iso-8859-8-bmp.html">index ISO-8859-8 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-8-i">ISO-8859-8-I</dfn> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-10">ISO-8859-10</dfn>
      <td><a href="index-iso-8859-10.txt">index-iso-8859-10.txt</a>
      <td><a href="iso-8859-10.html">index ISO-8859-10 visualization</a>
      <td><a href="iso-8859-10-bmp.html">index ISO-8859-10 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-13">ISO-8859-13</dfn>
      <td><a href="index-iso-8859-13.txt">index-iso-8859-13.txt</a>
      <td><a href="iso-8859-13.html">index ISO-8859-13 visualization</a>
      <td><a href="iso-8859-13-bmp.html">index ISO-8859-13 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-14">ISO-8859-14</dfn>
      <td><a href="index-iso-8859-14.txt">index-iso-8859-14.txt</a>
      <td><a href="iso-8859-14.html">index ISO-8859-14 visualization</a>
      <td><a href="iso-8859-14-bmp.html">index ISO-8859-14 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-15">ISO-8859-15</dfn>
      <td><a href="index-iso-8859-15.txt">index-iso-8859-15.txt</a>
      <td><a href="iso-8859-15.html">index ISO-8859-15 visualization</a>
      <td><a href="iso-8859-15-bmp.html">index ISO-8859-15 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="iso-8859-16">ISO-8859-16</dfn>
      <td><a href="index-iso-8859-16.txt">index-iso-8859-16.txt</a>
      <td><a href="iso-8859-16.html">index ISO-8859-16 visualization</a>
      <td><a href="iso-8859-16-bmp.html">index ISO-8859-16 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="koi8-r">KOI8-R</dfn>
      <td><a href="index-koi8-r.txt">index-koi8-r.txt</a>
      <td><a href="koi8-r.html">index KOI8-R visualization</a>
      <td><a href="koi8-r-bmp.html">index KOI8-R BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="koi8-u">KOI8-U</dfn>
      <td><a href="index-koi8-u.txt">index-koi8-u.txt</a>
      <td><a href="koi8-u.html">index KOI8-U visualization</a>
      <td><a href="koi8-u-bmp.html">index KOI8-U BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="macintosh">macintosh</dfn>
      <td><a href="index-macintosh.txt">index-macintosh.txt</a>
      <td><a href="macintosh.html">index macintosh visualization</a>
      <td><a href="macintosh-bmp.html">index macintosh BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-874">windows-874</dfn>
      <td><a href="index-windows-874.txt">index-windows-874.txt</a>
      <td><a href="windows-874.html">index windows-874 visualization</a>
      <td><a href="windows-874-bmp.html">index windows-874 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1250">windows-1250</dfn>
      <td><a href="index-windows-1250.txt">index-windows-1250.txt</a>
      <td><a href="windows-1250.html">index windows-1250 visualization</a>
      <td><a href="windows-1250-bmp.html">index windows-1250 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1251">windows-1251</dfn>
      <td><a href="index-windows-1251.txt">index-windows-1251.txt</a>
      <td><a href="windows-1251.html">index windows-1251 visualization</a>
      <td><a href="windows-1251-bmp.html">index windows-1251 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1252">windows-1252</dfn>
      <td><a href="index-windows-1252.txt">index-windows-1252.txt</a>
      <td><a href="windows-1252.html">index windows-1252 visualization</a>
      <td><a href="windows-1252-bmp.html">index windows-1252 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1253">windows-1253</dfn>
      <td><a href="index-windows-1253.txt">index-windows-1253.txt</a>
      <td><a href="windows-1253.html">index windows-1253 visualization</a>
      <td><a href="windows-1253-bmp.html">index windows-1253 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1254">windows-1254</dfn>
      <td><a href="index-windows-1254.txt">index-windows-1254.txt</a>
      <td><a href="windows-1254.html">index windows-1254 visualization</a>
      <td><a href="windows-1254-bmp.html">index windows-1254 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1255">windows-1255</dfn>
      <td><a href="index-windows-1255.txt">index-windows-1255.txt</a>
      <td><a href="windows-1255.html">index windows-1255 visualization</a>
      <td><a href="windows-1255-bmp.html">index windows-1255 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1256">windows-1256</dfn>
      <td><a href="index-windows-1256.txt">index-windows-1256.txt</a>
      <td><a href="windows-1256.html">index windows-1256 visualization</a>
      <td><a href="windows-1256-bmp.html">index windows-1256 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1257">windows-1257</dfn>
      <td><a href="index-windows-1257.txt">index-windows-1257.txt</a>
      <td><a href="windows-1257.html">index windows-1257 visualization</a>
      <td><a href="windows-1257-bmp.html">index windows-1257 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="windows-1258">windows-1258</dfn>
      <td><a href="index-windows-1258.txt">index-windows-1258.txt</a>
      <td><a href="windows-1258.html">index windows-1258 visualization</a>
      <td><a href="windows-1258-bmp.html">index windows-1258 BMP coverage</a> 
     <tr>
      <td><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="x-mac-cyrillic">x-mac-cyrillic</dfn>
      <td><a href="index-x-mac-cyrillic.txt">index-x-mac-cyrillic.txt</a>
      <td><a href="x-mac-cyrillic.html">index x-mac-cyrillic visualization</a>
      <td><a href="x-mac-cyrillic-bmp.html">index x-mac-cyrillic BMP coverage</a> 
   </table>
   <p class="note" role="note"><a data-link-type="dfn" href="#iso-8859-8" id="ref-for-iso-8859-8①">ISO-8859-8</a> and <a data-link-type="dfn" href="#iso-8859-8-i" id="ref-for-iso-8859-8-i①">ISO-8859-8-I</a> are
distinct <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②③">encoding</a> <a data-link-type="dfn" href="#name" id="ref-for-name⑥">names</a>, because <a data-link-type="dfn" href="#iso-8859-8" id="ref-for-iso-8859-8②">ISO-8859-8</a> has influence on the layout direction. And although
historically this might have been the case for <a data-link-type="dfn" href="#iso-8859-6" id="ref-for-iso-8859-6①">ISO-8859-6</a> and
"ISO-8859-6-I" as well, that is no longer true. </p>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="9.1" data-lt="single-byte decoder" id="single-byte-decoder"><span class="secno">9.1. </span><span class="content">single-byte decoder</span></h3>
   <p><a data-link-type="dfn" href="#single-byte-encoding" id="ref-for-single-byte-encoding③">Single-byte encodings</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②①">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler⑥">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①②">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished⑦">finished</a>. </p>
    <li>
     <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte①">ASCII byte</a>, return a code point whose value
 is <var>byte</var>. </p>
    <li>
     <p>Let <var>code point</var> be the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point">index code point</a> for <var>byte</var> − 0x80 in <a data-link-type="dfn" href="#index-single-byte" id="ref-for-index-single-byte①">index single-byte</a>. </p>
    <li>
     <p>If <var>code point</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error①③">error</a>. </p>
    <li>
     <p>Return a code point whose value is <var>code point</var>. </p>
   </ol>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="9.2" data-lt="single-byte encoder" id="single-byte-encoder"><span class="secno">9.2. </span><span class="content">single-byte encoder</span></h3>
   <p><a data-link-type="dfn" href="#single-byte-encoding" id="ref-for-single-byte-encoding④">Single-byte encodings</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①⑤">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler⑦">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①③">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished⑧">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point②">ASCII code point</a>, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>Let <var>pointer</var> be the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer②">index pointer</a> for <var>code point</var> in <a data-link-type="dfn" href="#index-single-byte" id="ref-for-index-single-byte②">index single-byte</a>. </p>
    <li>
     <p>If <var>pointer</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error①④">error</a> with <var>code point</var>. </p>
    <li>
     <p>Return a byte whose value is <var>pointer</var> + 0x80. </p>
   </ol>
   <h2 class="heading settled" data-level="10" id="legacy-multi-byte-chinese-(simplified)-encodings"><span class="secno">10. </span><span class="content">Legacy multi-byte Chinese (simplified) encodings</span><a class="self-link" href="#legacy-multi-byte-chinese-(simplified)-encodings"></a></h2>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="10.1" data-lt="GBK" id="gbk"><span class="secno">10.1. </span><span class="content">GBK</span></h3>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="10.1.1" data-lt="GBK decoder" id="gbk-decoder"><span class="secno">10.1.1. </span><span class="content">GBK decoder</span><a class="self-link" href="#gbk-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#gbk" id="ref-for-gbk①">GBK</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②②">decoder</a> is <a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030①">gb18030</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②③">decoder</a>. </p>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="10.1.2" data-lt="GBK encoder" id="gbk-encoder"><span class="secno">10.1.2. </span><span class="content">GBK encoder</span><a class="self-link" href="#gbk-encoder"></a></h4>
   <p><a data-link-type="dfn" href="#gbk" id="ref-for-gbk②">GBK</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①⑥">encoder</a> is <a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030②">gb18030</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①⑦">encoder</a> with its <a data-link-type="dfn" href="#gbk-flag" id="ref-for-gbk-flag">GBK flag</a> set. </p>
   <p class="note no-backref" role="note">Not fully aliasing <a data-link-type="dfn" href="#gbk" id="ref-for-gbk③">GBK</a> with <a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030③">gb18030</a> is a conservative move to decrease the chances of breaking legacy servers and other
consumers of content generated with <a data-link-type="dfn" href="#gbk" id="ref-for-gbk④">GBK</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①⑧">encoder</a>. </p>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="10.2" data-lt="gb18030" id="gb18030"><span class="secno">10.2. </span><span class="content">gb18030</span></h3>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="10.2.1" data-lt="gb18030 decoder" id="gb18030-decoder"><span class="secno">10.2.1. </span><span class="content">gb18030 decoder</span><a class="self-link" href="#gb18030-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030④">gb18030</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②④">decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="gb18030-first">gb18030 first</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="gb18030-second">gb18030 second</dfn>, and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="gb18030-third">gb18030 third</dfn> (all initially 0x00). </p>
   <p><a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030⑤">gb18030</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②⑤">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler⑧">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①④">end-of-stream</a> and <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first">gb18030 first</a>, <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second">gb18030 second</a>, and <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third">gb18030 third</a> are 0x00, return <a data-link-type="dfn" href="#finished" id="ref-for-finished⑨">finished</a>. </p>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①⑤">end-of-stream</a>, and <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first①">gb18030 first</a>, <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second①">gb18030 second</a>, or <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third①">gb18030 third</a> is not 0x00, set <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first②">gb18030 first</a>, <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second②">gb18030 second</a>, and <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third②">gb18030 third</a> to 0x00, and return <a data-link-type="dfn" href="#error" id="ref-for-error①⑤">error</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third③">gb18030 third</a> is not 0x00, then: </p>
     <ol>
      <li>
       <p>If <var>byte</var> is not in the range 0x30 to 0x39, inclusive, then: </p>
       <ol>
        <li>
         <p><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend⑥">Prepend</a> <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second③">gb18030 second</a>, <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third④">gb18030 third</a>, and <var>byte</var> to <var>stream</var>. </p>
        <li>
         <p>Set <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first③">gb18030 first</a>, <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second④">gb18030 second</a>, and <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third⑤">gb18030 third</a> to 0x00. </p>
        <li>
         <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error①⑥">error</a>. </p>
       </ol>
      <li>
       <p>Let <var>code point</var> be the <a data-link-type="dfn" href="#index-gb18030-ranges-code-point" id="ref-for-index-gb18030-ranges-code-point①">index gb18030 ranges code point</a> for
   ((<a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first④">gb18030 first</a> − 0x81) × (10 × 126 × 10)) +
   ((<a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second⑤">gb18030 second</a> − 0x30) × (10 × 126)) +
   ((<a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third⑥">gb18030 third</a> − 0x81) × 10) + <var>byte</var> − 0x30. </p>
      <li>
       <p>Set <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first⑤">gb18030 first</a>, <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second⑥">gb18030 second</a>, and <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third⑦">gb18030 third</a> to 0x00. </p>
      <li>
       <p>If <var>code point</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error①⑦">error</a>. </p>
      <li>
       <p>Return a code point whose value is <var>code point</var>. </p>
     </ol>
    <li>
     <p>If <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second⑦">gb18030 second</a> is not 0x00, then: </p>
     <ol>
      <li>
       <p>If <var>byte</var> is in the range 0x81 to 0xFE, inclusive, set <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third⑧">gb18030 third</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue⑦">continue</a>. </p>
      <li>
       <p><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend⑦">Prepend</a> <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second⑧">gb18030 second</a> followed by <var>byte</var> to <var>stream</var>, set <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first⑥">gb18030 first</a> and <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second⑨">gb18030 second</a> to 0x00, and return <a data-link-type="dfn" href="#error" id="ref-for-error①⑧">error</a>. </p>
     </ol>
    <li>
     <p>If <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first⑦">gb18030 first</a> is not 0x00, then: </p>
     <ol>
      <li>
       <p>If <var>byte</var> is in the range 0x30 to 0x39, inclusive, set <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second①⓪">gb18030 second</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue⑧">continue</a>. </p>
      <li>
       <p>Let <var>lead</var> be <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first⑧">gb18030 first</a>, let <var>pointer</var> be null, and set <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first⑨">gb18030 first</a> to 0x00. </p>
      <li>
       <p>Let <var>offset</var> be 0x40 if <var>byte</var> is
   less than 0x7F and 0x41 otherwise. </p>
      <li>
       <p>If <var>byte</var> is in the range 0x40 to 0x7E, inclusive, or
   0x80 to 0xFE, inclusive, set <var>pointer</var> to
   (<var>lead</var> − 0x81) × 190 + (<var>byte</var> − <var>offset</var>). </p>
      <li>
       <p>Let <var>code point</var> be null if <var>pointer</var> is null and the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point①">index code point</a> for <var>pointer</var> in <a data-link-type="dfn" href="#index-gb18030" id="ref-for-index-gb18030">index gb18030</a> otherwise. </p>
      <li>
       <p>If <var>code point</var> is non-null, return a code point whose value is <var>code point</var>. </p>
      <li>
       <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte②">ASCII byte</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend⑧">prepend</a> <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error①⑨">error</a>. </p>
     </ol>
    <li>
     <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte③">ASCII byte</a>, return
 a code point whose value is <var>byte</var>. </p>
    <li>
     <p>If <var>byte</var> is 0x80, return code point U+20AC. </p>
    <li>
     <p>If <var>byte</var> is in the range 0x81 to 0xFE, inclusive, set <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first①⓪">gb18030 first</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue⑨">continue</a>. </p>
    <li>
     <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error②⓪">error</a>. </p>
   </ol>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="10.2.2" data-lt="gb18030 encoder" id="gb18030-encoder"><span class="secno">10.2.2. </span><span class="content">gb18030 encoder</span><a class="self-link" href="#gb18030-encoder"></a></h4>
   <p><a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030⑥">gb18030</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder①⑨">encoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="gbk-flag">GBK flag</dfn> (initially unset). </p>
   <p><a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030⑦">gb18030</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②⓪">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler⑨">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①⑥">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished①⓪">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point③">ASCII code point</a>, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>If <var>code point</var> is U+E5E5, return <a data-link-type="dfn" href="#error" id="ref-for-error②①">error</a> with <var>code point</var>. </p>
     <p class="note" role="note"><a data-link-type="dfn" href="#index-gb18030" id="ref-for-index-gb18030①">Index gb18030</a> maps 0xA3 0xA0 to U+3000 rather than U+E5E5 for
  compatibility with deployed content. Therefore it cannot roundtrip. </p>
    <li>
     <p>If the <a data-link-type="dfn" href="#gbk-flag" id="ref-for-gbk-flag①">GBK flag</a> is set and <var>code point</var> is
 U+20AC, return byte 0x80. </p>
    <li>
     <p>Let <var>pointer</var> be the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer③">index pointer</a> for <var>code point</var> in <a data-link-type="dfn" href="#index-gb18030" id="ref-for-index-gb18030②">index gb18030</a>. </p>
    <li>
     <p>If <var>pointer</var> is non-null, then: </p>
     <ol>
      <li>
       <p>Let <var>lead</var> be <var>pointer</var> / 190 + 0x81. </p>
      <li>
       <p>Let <var>trail</var> be <var>pointer</var> % 190. </p>
      <li>
       <p>Let <var>offset</var> be 0x40 if <var>trail</var> is
   less than 0x3F and 0x41 otherwise. </p>
      <li>
       <p>Return two bytes whose values are <var>lead</var> and <var>trail</var> + <var>offset</var>. </p>
     </ol>
    <li>
     <p>If <a data-link-type="dfn" href="#gbk-flag" id="ref-for-gbk-flag②">GBK flag</a> is set, return <a data-link-type="dfn" href="#error" id="ref-for-error②②">error</a> with <var>code point</var>. </p>
    <li>
     <p>Set <var>pointer</var> to the <a data-link-type="dfn" href="#index-gb18030-ranges-pointer" id="ref-for-index-gb18030-ranges-pointer①">index gb18030 ranges pointer</a> for <var>code point</var>. </p>
    <li>
     <p>Let <var>byte1</var> be <var>pointer</var> / (10 × 126 × 10). </p>
    <li>
     <p>Set <var>pointer</var> to <var>pointer</var> % (10 × 126 × 10). </p>
    <li>
     <p>Let <var>byte2</var> be <var>pointer</var> / (10 × 126). </p>
    <li>
     <p>Set <var>pointer</var> to <var>pointer</var> % (10 × 126). </p>
    <li>
     <p>Let <var>byte3</var> be <var>pointer</var> / 10. </p>
    <li>
     <p>Let <var>byte4</var> be <var>pointer</var> % 10. </p>
    <li>
     <p>Return four bytes whose values are <var>byte1</var> + 0x81, <var>byte2</var> + 0x30, <var>byte3</var> + 0x81, <var>byte4</var> + 0x30. </p>
   </ol>
   <h2 class="heading settled" data-level="11" id="legacy-multi-byte-chinese-(traditional)-encodings"><span class="secno">11. </span><span class="content">Legacy multi-byte Chinese (traditional) encodings</span><a class="self-link" href="#legacy-multi-byte-chinese-(traditional)-encodings"></a></h2>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="11.1" data-lt="Big5" id="big5"><span class="secno">11.1. </span><span class="content">Big5</span></h3>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="11.1.1" data-lt="Big5 decoder" id="big5-decoder"><span class="secno">11.1.1. </span><span class="content">Big5 decoder</span><a class="self-link" href="#big5-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#big5" id="ref-for-big5①">Big5</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②⑥">decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="big5-lead">Big5 lead</dfn> (initially 0x00). </p>
   <p><a data-link-type="dfn" href="#big5" id="ref-for-big5②">Big5</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②⑦">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①⓪">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps:</p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①⑦">end-of-stream</a> and <a data-link-type="dfn" href="#big5-lead" id="ref-for-big5-lead">Big5 lead</a> is not 0x00, set <a data-link-type="dfn" href="#big5-lead" id="ref-for-big5-lead①">Big5 lead</a> to 0x00 and return <a data-link-type="dfn" href="#error" id="ref-for-error②③">error</a>. </p>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①⑧">end-of-stream</a> and <a data-link-type="dfn" href="#big5-lead" id="ref-for-big5-lead②">Big5 lead</a> is 0x00, return <a data-link-type="dfn" href="#finished" id="ref-for-finished①①">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#big5-lead" id="ref-for-big5-lead③">Big5 lead</a> is not 0x00, let <var>lead</var> be <a data-link-type="dfn" href="#big5-lead" id="ref-for-big5-lead④">Big5 lead</a>, let <var>pointer</var> be null, set <a data-link-type="dfn" href="#big5-lead" id="ref-for-big5-lead⑤">Big5 lead</a> to 0x00, and then: </p>
     <ol>
      <li>
       <p>Let <var>offset</var> be 0x40 if <var>byte</var> is
   less than 0x7F and 0x62 otherwise. </p>
      <li>
       <p>If <var>byte</var> is in the range 0x40 to 0x7E, inclusive, or
   0xA1 to 0xFE, inclusive, set <var>pointer</var> to
   (<var>lead</var> − 0x81) × 157 + (<var>byte</var> − <var>offset</var>). </p>
      <li>
       <p>If there is a row in the table below whose first column is <var>pointer</var>, return the <em>two</em> code points listed in
    its second column (the third column is irrelevant): </p>
       <table>
        <tbody>
         <tr>
          <th>Pointer
          <th>Code points
          <th>Notes 
         <tr>
          <td>1133
          <td>U+00CA U+0304
          <td>Ê̄ (LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON) 
         <tr>
          <td>1135
          <td>U+00CA U+030C
          <td>Ê̌ (LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON) 
         <tr>
          <td>1164
          <td>U+00EA U+0304
          <td>ê̄ (LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON) 
         <tr>
          <td>1166
          <td>U+00EA U+030C
          <td>ê̌ (LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON) 
       </table>
       <p class="note" role="note">Since <a data-link-type="dfn" href="#index" id="ref-for-index①②">indexes</a> are limited to
    single code points this table is used for these pointers. </p>
      <li>
       <p>Let <var>code point</var> be null if <var>pointer</var> is null and the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point②">index code point</a> for <var>pointer</var> in <a data-link-type="dfn" href="#index-big5" id="ref-for-index-big5①">index Big5</a> otherwise. </p>
      <li>
       <p>If <var>code point</var> is non-null, return a code point whose value is <var>code point</var>. </p>
      <li>
       <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte④">ASCII byte</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend⑨">prepend</a> <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error②④">error</a>. </p>
     </ol>
    <li>
     <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte⑤">ASCII byte</a>, return
 a code point whose value is <var>byte</var>. </p>
    <li>
     <p>If <var>byte</var> is in the range 0x81 to 0xFE, inclusive, set <a data-link-type="dfn" href="#big5-lead" id="ref-for-big5-lead⑥">Big5 lead</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①⓪">continue</a>. </p>
    <li>
     <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error②⑤">error</a>. </p>
   </ol>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="11.1.2" data-lt="Big5 encoder" id="big5-encoder"><span class="secno">11.1.2. </span><span class="content">Big5 encoder</span><a class="self-link" href="#big5-encoder"></a></h4>
   <p><a data-link-type="dfn" href="#big5" id="ref-for-big5③">Big5</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②①">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①①">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream①⑨">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished①②">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point④">ASCII code point</a>, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>Let <var>pointer</var> be the <a data-link-type="dfn" href="#index-big5-pointer" id="ref-for-index-big5-pointer">index Big5 pointer</a> for <var>code point</var>. </p>
    <li>
     <p>If <var>pointer</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error②⑥">error</a> with <var>code point</var>. </p>
    <li>
     <p>Let <var>lead</var> be <var>pointer</var> / 157 + 0x81. </p>
    <li>
     <p>Let <var>trail</var> be <var>pointer</var> % 157. </p>
    <li>
     <p>Let <var>offset</var> be 0x40 if <var>trail</var> is
 less than 0x3F and 0x62 otherwise. </p>
    <li>
     <p>Return two bytes whose values are <var>lead</var> and <var>trail</var> + <var>offset</var>. </p>
   </ol>
   <h2 class="heading settled" data-level="12" id="legacy-multi-byte-japanese-encodings"><span class="secno">12. </span><span class="content">Legacy multi-byte Japanese encodings</span><a class="self-link" href="#legacy-multi-byte-japanese-encodings"></a></h2>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="12.1" data-lt="EUC-JP" id="euc-jp"><span class="secno">12.1. </span><span class="content">EUC-JP</span></h3>
   <h4 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="12.1.1" data-lt="EUC-JP decoder" id="euc-jp-decoder"><span class="secno">12.1.1. </span><span class="content">EUC-JP decoder</span></h4>
   <p><a data-link-type="dfn" href="#euc-jp" id="ref-for-euc-jp①">EUC-JP</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②⑧">decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="euc-jp-jis0212-flag">EUC-JP jis0212 flag</dfn> (initially unset) and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="euc-jp-lead">EUC-JP lead</dfn> (initially 0x00). </p>
   <p><a data-link-type="dfn" href="#euc-jp" id="ref-for-euc-jp②">EUC-JP</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder②⑨">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①②">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②⓪">end-of-stream</a> and <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead">EUC-JP lead</a> is not 0x00, set <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead①">EUC-JP lead</a> to 0x00, and return <a data-link-type="dfn" href="#error" id="ref-for-error②⑦">error</a>. </p>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②①">end-of-stream</a> and <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead②">EUC-JP lead</a> is 0x00, return <a data-link-type="dfn" href="#finished" id="ref-for-finished①③">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead③">EUC-JP lead</a> is 0x8E and <var>byte</var> is
 in the range 0xA1 to 0xDF, inclusive, set <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead④">EUC-JP lead</a> to 0x00 and return
 a code point whose value is 0xFF61 − 0xA1 + <var>byte</var>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead⑤">EUC-JP lead</a> is 0x8F and <var>byte</var> is in the range
 0xA1 to 0xFE, inclusive, set the <a data-link-type="dfn" href="#euc-jp-jis0212-flag" id="ref-for-euc-jp-jis0212-flag">EUC-JP jis0212 flag</a>, set <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead⑥">EUC-JP lead</a> to <var>byte</var>, and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①①">continue</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead⑦">EUC-JP lead</a> is not 0x00, let <var>lead</var> be <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead⑧">EUC-JP lead</a>, set <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead⑨">EUC-JP lead</a> to 0x00, and then: </p>
     <ol>
      <li>
       <p>Let <var>code point</var> be null. </p>
      <li>
       <p>If <var>lead</var> and <var>byte</var> are both in the
   range 0xA1 to 0xFE, inclusive, set <var>code point</var> to the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point③">index code point</a> for
   (<var>lead</var> − 0xA1) × 94 + <var>byte</var> − 0xA1
   in <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208③">index jis0208</a> if the <a data-link-type="dfn" href="#euc-jp-jis0212-flag" id="ref-for-euc-jp-jis0212-flag①">EUC-JP jis0212 flag</a> is unset and in <a data-link-type="dfn" href="#index-jis0212" id="ref-for-index-jis0212">index jis0212</a> otherwise. </p>
      <li>
       <p>Unset the <a data-link-type="dfn" href="#euc-jp-jis0212-flag" id="ref-for-euc-jp-jis0212-flag②">EUC-JP jis0212 flag</a>. </p>
      <li>
       <p>If <var>code point</var> is non-null, return a code point whose value is <var>code point</var>. </p>
      <li>
       <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte⑥">ASCII byte</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①⓪">prepend</a> <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error②⑧">error</a>. </p>
     </ol>
    <li>
     <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte⑦">ASCII byte</a>, return
 a code point whose value is <var>byte</var>. </p>
    <li>
     <p>If <var>byte</var> is 0x8E, 0x8F, or in the range 0xA1 to
 0xFE, inclusive, set <a data-link-type="dfn" href="#euc-jp-lead" id="ref-for-euc-jp-lead①⓪">EUC-JP lead</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①②">continue</a>. </p>
    <li>
     <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error②⑨">error</a>. </p>
   </ol>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="12.1.2" data-lt="EUC-JP encoder" id="euc-jp-encoder"><span class="secno">12.1.2. </span><span class="content">EUC-JP encoder</span><a class="self-link" href="#euc-jp-encoder"></a></h4>
   <p><a data-link-type="dfn" href="#euc-jp" id="ref-for-euc-jp③">EUC-JP</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②②">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①③">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②②">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished①④">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point⑤">ASCII code point</a>, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>If <var>code point</var> is U+00A5, return byte 0x5C. </p>
    <li>
     <p>If <var>code point</var> is U+203E, return byte 0x7E. </p>
    <li>
     <p>If <var>code point</var> is in the range U+FF61 to U+FF9F, inclusive, return
 two bytes whose values are 0x8E and <var>code point</var> − 0xFF61 + 0xA1. </p>
    <li>
     <p>If <var>code point</var> is U+2212, set it to U+FF0D. </p>
    <li>
     <p>Let <var>pointer</var> be the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer④">index pointer</a> for <var>code point</var> in <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208④">index jis0208</a>. </p>
     <p class="note" role="note">If <var>pointer</var> is non-null, it is less than 8836 due to the nature of <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208⑤">index jis0208</a> and the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer⑤">index pointer</a> operation. </p>
    <li>
     <p>If <var>pointer</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error③⓪">error</a> with <var>code point</var>. </p>
    <li>
     <p>Let <var>lead</var> be <var>pointer</var> / 94 + 0xA1. </p>
    <li>
     <p>Let <var>trail</var> be <var>pointer</var> % 94 + 0xA1. </p>
    <li>
     <p>Return two bytes whose values are <var>lead</var> and <var>trail</var>. </p>
   </ol>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="12.2" data-lt="ISO-2022-JP" id="iso-2022-jp"><span class="secno">12.2. </span><span class="content">ISO-2022-JP</span></h3>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="12.2.1" data-lt="ISO-2022-JP decoder" id="iso-2022-jp-decoder"><span class="secno">12.2.1. </span><span class="content">ISO-2022-JP decoder</span><a class="self-link" href="#iso-2022-jp-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#iso-2022-jp" id="ref-for-iso-2022-jp②">ISO-2022-JP</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③⓪">decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="iso-2022-jp-decoder-state">ISO-2022-JP decoder state</dfn> (initially <a data-link-type="dfn" href="#iso-2022-jp-decoder-ascii" id="ref-for-iso-2022-jp-decoder-ascii">ASCII</a>), <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="iso-2022-jp-decoder-output-state">ISO-2022-JP decoder output state</dfn> (initially <a data-link-type="dfn" href="#iso-2022-jp-decoder-ascii" id="ref-for-iso-2022-jp-decoder-ascii①">ASCII</a>), <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="iso-2022-jp-lead">ISO-2022-JP lead</dfn> (initially 0x00), and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="iso-2022-jp-output-flag">ISO-2022-JP output flag</dfn> (initially unset). </p>
   <p><a data-link-type="dfn" href="#iso-2022-jp" id="ref-for-iso-2022-jp③">ISO-2022-JP</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③①">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①④">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps, switching on <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state">ISO-2022-JP decoder state</a>: </p>
   <dl class="switch">
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP decoder ASCII" data-noexport id="iso-2022-jp-decoder-ascii">ASCII</dfn> 
    <dd>
     <p>Based on <var>byte</var>: </p>
     <dl class="switch">
      <dt>0x1B 
      <dd>
       <p>Set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state①">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-escape-start" id="ref-for-iso-2022-jp-decoder-escape-start">escape start</a> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①③">continue</a>. </p>
      <dt>0x00 to 0x7F, excluding 0x0E, 0x0F, and 0x1B 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag">ISO-2022-JP output flag</a> and return a code point whose
   value is <var>byte</var>. </p>
      <dt><a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②③">end-of-stream</a> 
      <dd>
       <p>Return <a data-link-type="dfn" href="#finished" id="ref-for-finished①⑤">finished</a>. </p>
      <dt>Otherwise 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag①">ISO-2022-JP output flag</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error③①">error</a>. </p>
     </dl>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP decoder Roman" data-noexport id="iso-2022-jp-decoder-roman">Roman</dfn> 
    <dd>
     <p>Based on <var>byte</var>: </p>
     <dl class="switch">
      <dt>0x1B 
      <dd>
       <p>Set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state②">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-escape-start" id="ref-for-iso-2022-jp-decoder-escape-start①">escape start</a> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①④">continue</a>. </p>
      <dt>0x5C 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag②">ISO-2022-JP output flag</a> and return code point U+00A5. </p>
      <dt>0x7E 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag③">ISO-2022-JP output flag</a> and return code point U+203E. </p>
      <dt>0x00 to 0x7F, excluding 0x0E, 0x0F, 0x1B, 0x5C, and 0x7E 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag④">ISO-2022-JP output flag</a> and return a code point whose
   value is <var>byte</var>. </p>
      <dt><a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②④">end-of-stream</a> 
      <dd>
       <p>Return <a data-link-type="dfn" href="#finished" id="ref-for-finished①⑥">finished</a>. </p>
      <dt>Otherwise 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag⑤">ISO-2022-JP output flag</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error③②">error</a>. </p>
     </dl>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP decoder katakana" data-noexport id="iso-2022-jp-decoder-katakana">katakana</dfn> 
    <dd>
     <p>Based on <var>byte</var>: </p>
     <dl class="switch">
      <dt>0x1B 
      <dd>
       <p>Set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state③">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-escape-start" id="ref-for-iso-2022-jp-decoder-escape-start②">escape start</a> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①⑤">continue</a>. </p>
      <dt>0x21 to 0x5F 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag⑥">ISO-2022-JP output flag</a> and return a code point whose
   value is 0xFF61 − 0x21 + <var>byte</var>. </p>
      <dt><a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②⑤">end-of-stream</a> 
      <dd>
       <p>Return <a data-link-type="dfn" href="#finished" id="ref-for-finished①⑦">finished</a>. </p>
      <dt>Otherwise 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag⑦">ISO-2022-JP output flag</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error③③">error</a>. </p>
     </dl>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP decoder lead byte" data-noexport id="iso-2022-jp-decoder-lead-byte">Lead byte</dfn> 
    <dd>
     <p>Based on <var>byte</var>: </p>
     <dl class="switch">
      <dt>0x1B 
      <dd>
       <p>Set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state④">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-escape-start" id="ref-for-iso-2022-jp-decoder-escape-start③">escape start</a> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①⑥">continue</a>. </p>
      <dt>0x21 to 0x7E 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag⑧">ISO-2022-JP output flag</a>, set <a data-link-type="dfn" href="#iso-2022-jp-lead" id="ref-for-iso-2022-jp-lead">ISO-2022-JP lead</a> to <var>byte</var>, <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state⑤">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-trail-byte" id="ref-for-iso-2022-jp-decoder-trail-byte">trail byte</a>, and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①⑦">continue</a>. </p>
      <dt><a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②⑥">end-of-stream</a> 
      <dd>
       <p>Return <a data-link-type="dfn" href="#finished" id="ref-for-finished①⑧">finished</a>. </p>
      <dt>Otherwise 
      <dd>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag⑨">ISO-2022-JP output flag</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error③④">error</a>. </p>
     </dl>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP decoder trail byte" data-noexport id="iso-2022-jp-decoder-trail-byte">Trail byte</dfn> 
    <dd>
     <p>Based on <var>byte</var>: </p>
     <dl class="switch">
      <dt>0x1B 
      <dd>
       <p>Set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state⑥">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-escape-start" id="ref-for-iso-2022-jp-decoder-escape-start④">escape start</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error③⑤">error</a>. </p>
      <dt>0x21 to 0x7E 
      <dd>
       <ol>
        <li>
         <p>Set the <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state⑦">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-lead-byte" id="ref-for-iso-2022-jp-decoder-lead-byte">lead byte</a>. </p>
        <li>
         <p>Let <var>pointer</var> be
     (<a data-link-type="dfn" href="#iso-2022-jp-lead" id="ref-for-iso-2022-jp-lead①">ISO-2022-JP lead</a> − 0x21) × 94 + <var>byte</var> − 0x21. </p>
        <li>
         <p>Let <var>code point</var> be the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point④">index code point</a> for <var>pointer</var> in <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208⑥">index jis0208</a>. </p>
        <li>
         <p>If <var>code point</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error③⑥">error</a>. </p>
        <li>
         <p>Return a code point whose value is <var>code point</var>. </p>
       </ol>
      <dt><a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②⑦">end-of-stream</a> 
      <dd>
       <p>Set the <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state⑧">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-lead-byte" id="ref-for-iso-2022-jp-decoder-lead-byte①">lead byte</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①①">prepend</a> <var>byte</var> to <var>stream</var>, and return <a data-link-type="dfn" href="#error" id="ref-for-error③⑦">error</a>. </p>
      <dt>Otherwise 
      <dd>
       <p>Set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state⑨">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-lead-byte" id="ref-for-iso-2022-jp-decoder-lead-byte②">lead byte</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error③⑧">error</a>. </p>
     </dl>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP decoder escape start" data-noexport id="iso-2022-jp-decoder-escape-start">Escape start</dfn> 
    <dd>
     <ol>
      <li>
       <p>If <var>byte</var> is either 0x24 or 0x28, set <a data-link-type="dfn" href="#iso-2022-jp-lead" id="ref-for-iso-2022-jp-lead②">ISO-2022-JP lead</a> to <var>byte</var>, <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state①⓪">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-escape" id="ref-for-iso-2022-jp-decoder-escape">escape</a>, and return <a data-link-type="dfn" href="#continue" id="ref-for-continue①⑧">continue</a>. </p>
      <li>
       <p><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①②">Prepend</a> <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag①⓪">ISO-2022-JP output flag</a>, set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state①①">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-output-state" id="ref-for-iso-2022-jp-decoder-output-state">ISO-2022-JP decoder output state</a>, and return <a data-link-type="dfn" href="#error" id="ref-for-error③⑨">error</a>. </p>
     </ol>
    <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP decoder escape" data-noexport id="iso-2022-jp-decoder-escape">Escape</dfn> 
    <dd>
     <ol>
      <li>
       <p>Let <var>lead</var> be <a data-link-type="dfn" href="#iso-2022-jp-lead" id="ref-for-iso-2022-jp-lead③">ISO-2022-JP lead</a> and set <a data-link-type="dfn" href="#iso-2022-jp-lead" id="ref-for-iso-2022-jp-lead④">ISO-2022-JP lead</a> to 0x00. </p>
      <li>
       <p>Let <var>state</var> be null. </p>
      <li>
       <p>If <var>lead</var> is 0x28 and <var>byte</var> is 0x42, set <var>state</var> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-ascii" id="ref-for-iso-2022-jp-decoder-ascii②">ASCII</a>. </p>
      <li>
       <p>If <var>lead</var> is 0x28 and <var>byte</var> is 0x4A, set <var>state</var> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-roman" id="ref-for-iso-2022-jp-decoder-roman">Roman</a>. </p>
      <li>
       <p>If <var>lead</var> is 0x28 and <var>byte</var> is 0x49, set <var>state</var> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-katakana" id="ref-for-iso-2022-jp-decoder-katakana">katakana</a>. </p>
      <li>
       <p>If <var>lead</var> is 0x24 and <var>byte</var> is either
   0x40 or 0x42, set <var>state</var> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-lead-byte" id="ref-for-iso-2022-jp-decoder-lead-byte③">lead byte</a>. </p>
      <li>
       <p>If <var>state</var> is non-null, then: </p>
       <ol>
        <li>
         <p>Set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state①②">ISO-2022-JP decoder state</a> and <a data-link-type="dfn" href="#iso-2022-jp-decoder-output-state" id="ref-for-iso-2022-jp-decoder-output-state①">ISO-2022-JP decoder output state</a> to <var>state</var>. </p>
        <li>
         <p>Let <var>output flag</var> be the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag①①">ISO-2022-JP output flag</a>. </p>
        <li>
         <p>Set the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag①②">ISO-2022-JP output flag</a>. </p>
        <li>
         <p>Return <a data-link-type="dfn" href="#continue" id="ref-for-continue①⑨">continue</a>, if <var>output flag</var> is unset, and <a data-link-type="dfn" href="#error" id="ref-for-error④⓪">error</a> otherwise. </p>
       </ol>
      <li>
       <p><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①③">Prepend</a> <var>lead</var> and <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Unset the <a data-link-type="dfn" href="#iso-2022-jp-output-flag" id="ref-for-iso-2022-jp-output-flag①③">ISO-2022-JP output flag</a>, set <a data-link-type="dfn" href="#iso-2022-jp-decoder-state" id="ref-for-iso-2022-jp-decoder-state①③">ISO-2022-JP decoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-decoder-output-state" id="ref-for-iso-2022-jp-decoder-output-state②">ISO-2022-JP decoder output state</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error④①">error</a>. </p>
     </ol>
   </dl>
   <h4 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="12.2.2" data-lt="ISO-2022-JP encoder" id="iso-2022-jp-encoder"><span class="secno">12.2.2. </span><span class="content">ISO-2022-JP encoder</span></h4>
   <div class="note no-backref" role="note">
    <p>The <a data-link-type="dfn" href="#iso-2022-jp-encoder" id="ref-for-iso-2022-jp-encoder①">ISO-2022-JP encoder</a> is the only <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②③">encoder</a> for which the concatenation of
 multiple outputs can result in an <a data-link-type="dfn" href="#error" id="ref-for-error④②">error</a> when run through the corresponding <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③②">decoder</a>. </p>
    <p class="example" id="example-iso-2022-jp-encoder-oddity"><a class="self-link" href="#example-iso-2022-jp-encoder-oddity"></a>Encoding U+00A5 gives 0x1B 0x28 0x4A 0x5C
 0x1B 0x28 0x42. Doing that twice, concatenating the results, and then decoding yields U+00A5 U+FFFD
 U+00A5. </p>
   </div>
   <p><a data-link-type="dfn" href="#iso-2022-jp" id="ref-for-iso-2022-jp④">ISO-2022-JP</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②④">encoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="iso-2022-jp-encoder-state">ISO-2022-JP encoder state</dfn> which is <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP encoder ASCII" data-noexport id="iso-2022-jp-encoder-ascii">ASCII</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP encoder Roman" data-noexport id="iso-2022-jp-encoder-roman">Roman</dfn>, or <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ISO-2022-JP encoder jis0208" data-noexport id="iso-2022-jp-encoder-jis0208">jis0208</dfn> (initially <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii">ASCII</a>). </p>
   <p><a data-link-type="dfn" href="#iso-2022-jp" id="ref-for-iso-2022-jp⑤">ISO-2022-JP</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②⑤">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①⑤">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②⑧">end-of-stream</a> and <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state">ISO-2022-JP encoder state</a> is not <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii①">ASCII</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①④">prepend</a> <var>code point</var> to <var>stream</var>, set <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state①">ISO-2022-JP encoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii②">ASCII</a>, and return three bytes
 0x1B 0x28 0x42. </p>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream②⑨">end-of-stream</a> and <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state②">ISO-2022-JP encoder state</a> is <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii③">ASCII</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished①⑨">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state③">ISO-2022-JP encoder state</a> is <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii④">ASCII</a> or <a data-link-type="dfn" href="#iso-2022-jp-encoder-roman" id="ref-for-iso-2022-jp-encoder-roman">Roman</a>, and <var>code point</var> is U+000E, U+000F,
  or U+001B, return <a data-link-type="dfn" href="#error" id="ref-for-error④③">error</a> with U+FFFD. </p>
     <p class="note" role="note">This returns U+FFFD rather than <var>code point</var> to prevent attacks. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state④">ISO-2022-JP encoder state</a> is <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii⑤">ASCII</a> and <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point⑥">ASCII code point</a>, return a byte whose value is <var>code point</var>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state⑤">ISO-2022-JP encoder state</a> is <a data-link-type="dfn" href="#iso-2022-jp-encoder-roman" id="ref-for-iso-2022-jp-encoder-roman①">Roman</a> and <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point⑦">ASCII code point</a>, excluding U+005C and U+007E, or is U+00A5 or
  U+203E, then: </p>
     <ol>
      <li>
       <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point⑧">ASCII code point</a>, return a byte
   whose value is <var>code point</var>. </p>
      <li>
       <p>If <var>code point</var> is U+00A5, return byte 0x5C. </p>
      <li>
       <p>If <var>code point</var> is U+203E, return byte 0x7E. </p>
     </ol>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point⑨">ASCII code point</a>, and <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state⑥">ISO-2022-JP encoder state</a> is not <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii⑥">ASCII</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①⑤">prepend</a> <var>code point</var> to <var>stream</var>, set <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state⑦">ISO-2022-JP encoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-encoder-ascii" id="ref-for-iso-2022-jp-encoder-ascii⑦">ASCII</a>, and return three bytes
 0x1B 0x28 0x42. </p>
    <li>
     <p>If <var>code point</var> is either U+00A5 or U+203E, and <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state⑧">ISO-2022-JP encoder state</a> is not <a data-link-type="dfn" href="#iso-2022-jp-encoder-roman" id="ref-for-iso-2022-jp-encoder-roman②">Roman</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①⑥">prepend</a> <var>code point</var> to <var>stream</var>, set <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state⑨">ISO-2022-JP encoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-encoder-roman" id="ref-for-iso-2022-jp-encoder-roman③">Roman</a>, and return three bytes
 0x1B 0x28 0x4A. </p>
    <li>
     <p>If <var>code point</var> is U+2212, set it to U+FF0D. </p>
    <li>
     <p>If <var>code point</var> is in the range U+FF61 to U+FF9F, inclusive, set it to the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point⑤">index code point</a> for <var>code point</var> − 0xFF61 in <a data-link-type="dfn" href="#index-iso-2022-jp-katakana" id="ref-for-index-iso-2022-jp-katakana②">index ISO-2022-JP katakana</a>. </p>
    <li>
     <p>Let <var>pointer</var> be the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer⑥">index pointer</a> for <var>code point</var> in <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208⑦">index jis0208</a>. </p>
     <p class="note" role="note">If <var>pointer</var> is non-null, it is less than 8836 due to the nature of <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208⑧">index jis0208</a> and the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer⑦">index pointer</a> operation. </p>
    <li>
     <p>If <var>pointer</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error④④">error</a> with <var>code point</var>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state①⓪">ISO-2022-JP encoder state</a> is not <a data-link-type="dfn" href="#iso-2022-jp-encoder-jis0208" id="ref-for-iso-2022-jp-encoder-jis0208">jis0208</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①⑦">prepend</a> <var>code point</var> to <var>stream</var>, set <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state①①">ISO-2022-JP encoder state</a> to <a data-link-type="dfn" href="#iso-2022-jp-encoder-jis0208" id="ref-for-iso-2022-jp-encoder-jis0208①">jis0208</a>, and return three bytes
 0x1B 0x24 0x42. </p>
    <li>
     <p>Let <var>lead</var> be <var>pointer</var> / 94 + 0x21. </p>
    <li>
     <p>Let <var>trail</var> be <var>pointer</var> % 94 + 0x21. </p>
    <li>
     <p>Return two bytes whose values are <var>lead</var> and <var>trail</var>. </p>
   </ol>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="12.3" data-lt="Shift_JIS" id="shift_jis"><span class="secno">12.3. </span><span class="content">Shift_JIS</span></h3>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="12.3.1" data-lt="Shift_JIS decoder" id="shift_jis-decoder"><span class="secno">12.3.1. </span><span class="content">Shift_JIS decoder</span><a class="self-link" href="#shift_jis-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#shift_jis" id="ref-for-shift_jis③">Shift_JIS</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③③">decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="shift_jis-lead">Shift_JIS lead</dfn> (initially 0x00). </p>
   <p><a data-link-type="dfn" href="#shift_jis" id="ref-for-shift_jis④">Shift_JIS</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③④">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①⑥">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③⓪">end-of-stream</a> and <a data-link-type="dfn" href="#shift_jis-lead" id="ref-for-shift_jis-lead">Shift_JIS lead</a> is not 0x00, set <a data-link-type="dfn" href="#shift_jis-lead" id="ref-for-shift_jis-lead①">Shift_JIS lead</a> to 0x00 and
 return <a data-link-type="dfn" href="#error" id="ref-for-error④⑤">error</a>. </p>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③①">end-of-stream</a> and <a data-link-type="dfn" href="#shift_jis-lead" id="ref-for-shift_jis-lead②">Shift_JIS lead</a> is 0x00, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②⓪">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#shift_jis-lead" id="ref-for-shift_jis-lead③">Shift_JIS lead</a> is not 0x00, let <var>lead</var> be <a data-link-type="dfn" href="#shift_jis-lead" id="ref-for-shift_jis-lead④">Shift_JIS lead</a>, let <var>pointer</var> be null, set <a data-link-type="dfn" href="#shift_jis-lead" id="ref-for-shift_jis-lead⑤">Shift_JIS lead</a> to 0x00, and then: </p>
     <ol>
      <li>
       <p>Let <var>offset</var> be 0x40, if <var>byte</var> is
   less than 0x7F, and 0x41 otherwise. </p>
      <li>
       <p>Let <var>lead offset</var> be 0x81, if <var>lead</var> is less than 0xA0, and 0xC1 otherwise. </p>
      <li>
       <p>If <var>byte</var> is in the range 0x40 to 0x7E, inclusive, or
   0x80 to 0xFC, inclusive, set <var>pointer</var> to
   (<var>lead</var> − <var>lead offset</var>) × 188 + <var>byte</var> − <var>offset</var>. </p>
      <li>
       <p>If <var>pointer</var> is in the range 8836 to 10715, inclusive, return a code point whose
    value is 0xE000 − 8836 + <var>pointer</var>. </p>
       <p class="note" role="note">This is interoperable legacy from Windows known as EUDC. </p>
      <li>
       <p>Let <var>code point</var> be null, if <var>pointer</var> is null, and the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point⑥">index code point</a> for <var>pointer</var> in <a data-link-type="dfn" href="#index-jis0208" id="ref-for-index-jis0208⑨">index jis0208</a> otherwise. </p>
      <li>
       <p>If <var>code point</var> is non-null, return a code point whose value is <var>code point</var>. </p>
      <li>
       <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte⑧">ASCII byte</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①⑧">prepend</a> <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error④⑥">error</a>. </p>
     </ol>
    <li>
     <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte⑨">ASCII byte</a> or 0x80, return a code point
 whose value is <var>byte</var>. </p>
    <li>
     <p>If <var>byte</var> is in the range 0xA1 to 0xDF, inclusive, return
 a code point whose value is 0xFF61 − 0xA1 + <var>byte</var>. </p>
    <li>
     <p>If <var>byte</var> is in the range 0x81 to 0x9F, inclusive, or 0xE0 to 0xFC,
 inclusive, set <a data-link-type="dfn" href="#shift_jis-lead" id="ref-for-shift_jis-lead⑥">Shift_JIS lead</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue②⓪">continue</a>. </p>
    <li>
     <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error④⑦">error</a>. </p>
   </ol>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="12.3.2" data-lt="Shift_JIS encoder" id="shift_jis-encoder"><span class="secno">12.3.2. </span><span class="content">Shift_JIS encoder</span><a class="self-link" href="#shift_jis-encoder"></a></h4>
   <p><a data-link-type="dfn" href="#shift_jis" id="ref-for-shift_jis⑤">Shift_JIS</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②⑥">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①⑦">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③②">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②①">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point①⓪">ASCII code point</a> or U+0080, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>If <var>code point</var> is U+00A5, return byte 0x5C. </p>
    <li>
     <p>If <var>code point</var> is U+203E, return byte 0x7E. </p>
    <li>
     <p>If <var>code point</var> is in the range U+FF61 to U+FF9F, inclusive, return
 a byte whose value is <var>code point</var> − 0xFF61 + 0xA1. </p>
    <li>
     <p>If <var>code point</var> is U+2212, set it to U+FF0D. </p>
    <li>
     <p>Let <var>pointer</var> be the <a data-link-type="dfn" href="#index-shift_jis-pointer" id="ref-for-index-shift_jis-pointer">index Shift_JIS pointer</a> for <var>code point</var>. </p>
    <li>
     <p>If <var>pointer</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error④⑧">error</a> with <var>code point</var>. </p>
    <li>
     <p>Let <var>lead</var> be <var>pointer</var> / 188. </p>
    <li>
     <p>Let <var>lead offset</var> be 0x81, if <var>lead</var> is
 less than 0x1F, and 0xC1 otherwise. </p>
    <li>
     <p>Let <var>trail</var> be <var>pointer</var> % 188. </p>
    <li>
     <p>Let <var>offset</var> be 0x40, if <var>trail</var> is
 less than 0x3F, and 0x41 otherwise. </p>
    <li>
     <p>Return two bytes whose values are <var>lead</var> + <var>lead offset</var> and <var>trail</var> + <var>offset</var>. </p>
   </ol>
   <h2 class="heading settled" data-level="13" id="legacy-multi-byte-korean-encodings"><span class="secno">13. </span><span class="content">Legacy multi-byte Korean encodings</span><a class="self-link" href="#legacy-multi-byte-korean-encodings"></a></h2>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="13.1" data-lt="EUC-KR" id="euc-kr"><span class="secno">13.1. </span><span class="content">EUC-KR</span></h3>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="13.1.1" data-lt="EUC-KR decoder" id="euc-kr-decoder"><span class="secno">13.1.1. </span><span class="content">EUC-KR decoder</span><a class="self-link" href="#euc-kr-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#euc-kr" id="ref-for-euc-kr①">EUC-KR</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③⑤">decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="euc-kr-lead">EUC-KR lead</dfn> (initially 0x00). </p>
   <p><a data-link-type="dfn" href="#euc-kr" id="ref-for-euc-kr②">EUC-KR</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③⑥">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①⑧">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③③">end-of-stream</a> and <a data-link-type="dfn" href="#euc-kr-lead" id="ref-for-euc-kr-lead">EUC-KR lead</a> is not 0x00, set <a data-link-type="dfn" href="#euc-kr-lead" id="ref-for-euc-kr-lead①">EUC-KR lead</a> to 0x00
 and return <a data-link-type="dfn" href="#error" id="ref-for-error④⑨">error</a>. </p>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③④">end-of-stream</a> and <a data-link-type="dfn" href="#euc-kr-lead" id="ref-for-euc-kr-lead②">EUC-KR lead</a> is 0x00, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②②">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#euc-kr-lead" id="ref-for-euc-kr-lead③">EUC-KR lead</a> is not 0x00, let <var>lead</var> be <a data-link-type="dfn" href="#euc-kr-lead" id="ref-for-euc-kr-lead④">EUC-KR lead</a>, let <var>pointer</var> be null, set <a data-link-type="dfn" href="#euc-kr-lead" id="ref-for-euc-kr-lead⑤">EUC-KR lead</a> to 0x00, and then: </p>
     <ol>
      <li>
       <p>If <var>byte</var> is in the range  0x41 to 0xFE, inclusive, set <var>pointer</var> to
   (<var>lead</var> − 0x81) × 190 + (<var>byte</var> − 0x41). </p>
      <li>
       <p>Let <var>code point</var> be null, if <var>pointer</var> is null,
   and the <a data-link-type="dfn" href="#index-code-point" id="ref-for-index-code-point⑦">index code point</a> for <var>pointer</var> in <a data-link-type="dfn" href="#index-euc-kr" id="ref-for-index-euc-kr">index EUC-KR</a> otherwise. </p>
      <li>
       <p>If <var>code point</var> is non-null, return a code point whose value is <var>code point</var>. </p>
      <li>
       <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte①⓪">ASCII byte</a>, <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend①⑨">prepend</a> <var>byte</var> to <var>stream</var>. </p>
      <li>
       <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error⑤⓪">error</a>. </p>
     </ol>
    <li>
     <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte①①">ASCII byte</a>, return
 a code point whose value is <var>byte</var>. </p>
    <li>
     <p>If <var>byte</var> is in the range 0x81 to 0xFE, inclusive, set <a data-link-type="dfn" href="#euc-kr-lead" id="ref-for-euc-kr-lead⑥">EUC-KR lead</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue②①">continue</a>. </p>
    <li>
     <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error⑤①">error</a>. </p>
   </ol>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="13.1.2" data-lt="EUC-KR encoder" id="euc-kr-encoder"><span class="secno">13.1.2. </span><span class="content">EUC-KR encoder</span><a class="self-link" href="#euc-kr-encoder"></a></h4>
   <p><a data-link-type="dfn" href="#euc-kr" id="ref-for-euc-kr③">EUC-KR</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②⑦">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler①⑨">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③⑤">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②③">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point①①">ASCII code point</a>, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>Let <var>pointer</var> be the <a data-link-type="dfn" href="#index-pointer" id="ref-for-index-pointer⑧">index pointer</a> for <var>code point</var> in <a data-link-type="dfn" href="#index-euc-kr" id="ref-for-index-euc-kr①">index EUC-KR</a>. </p>
    <li>
     <p>If <var>pointer</var> is null, return <a data-link-type="dfn" href="#error" id="ref-for-error⑤②">error</a> with <var>code point</var>. </p>
    <li>
     <p>Let <var>lead</var> be <var>pointer</var> / 190 + 0x81. </p>
    <li>
     <p>Let <var>trail</var> be <var>pointer</var> % 190 + 0x41. </p>
    <li>
     <p>Return two bytes whose values are <var>lead</var> and <var>trail</var>. </p>
   </ol>
   <h2 class="heading settled" data-level="14" id="legacy-miscellaneous-encodings"><span class="secno">14. </span><span class="content">Legacy miscellaneous encodings</span><a class="self-link" href="#legacy-miscellaneous-encodings"></a></h2>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="14.1" data-lt="replacement" id="replacement"><span class="secno">14.1. </span><span class="content">replacement</span></h3>
   <p class="note" role="note">The <a data-link-type="dfn" href="#replacement" id="ref-for-replacement⑨">replacement</a> <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②④">encoding</a> exists to prevent certain
attacks that abuse a mismatch between <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②⑤">encodings</a> supported on
the server and the client. </p>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="14.1.1" data-lt="replacement decoder" id="replacement-decoder"><span class="secno">14.1.1. </span><span class="content">replacement decoder</span><a class="self-link" href="#replacement-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#replacement" id="ref-for-replacement①⓪">replacement</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③⑦">decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="replacement-error-returned-flag">replacement error returned flag</dfn> (initially unset). </p>
   <p><a data-link-type="dfn" href="#replacement" id="ref-for-replacement①①">replacement</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③⑧">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler②⓪">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③⑥">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②④">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#replacement-error-returned-flag" id="ref-for-replacement-error-returned-flag">replacement error returned flag</a> is unset, set the <a data-link-type="dfn" href="#replacement-error-returned-flag" id="ref-for-replacement-error-returned-flag①">replacement error returned flag</a> and return <a data-link-type="dfn" href="#error" id="ref-for-error⑤③">error</a>. </p>
    <li>
     <p>Return <a data-link-type="dfn" href="#finished" id="ref-for-finished②⑤">finished</a>. </p>
   </ol>
   <h3 class="heading settled" data-level="14.2" id="common-infrastructure-for-utf-16be-and-utf-16le"><span class="secno">14.2. </span><span class="content">Common infrastructure for <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be⑨">UTF-16BE</a> and <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le⑨">UTF-16LE</a></span><a class="self-link" href="#common-infrastructure-for-utf-16be-and-utf-16le"></a></h3>
   <h4 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="14.2.1" data-lt="shared UTF-16 decoder" id="shared-utf-16-decoder"><span class="secno">14.2.1. </span><span class="content">shared UTF-16 decoder</span></h4>
   <p class="note no-backref" role="note">A byte order mark has priority over a <a data-link-type="dfn" href="#label" id="ref-for-label①⑤">label</a> as it
has been found to be more accurate in deployed content. Therefore it is not part of the <a data-link-type="dfn" href="#shared-utf-16-decoder" id="ref-for-shared-utf-16-decoder">shared UTF-16 decoder</a> algorithm but rather the <a data-link-type="dfn" href="#decode" id="ref-for-decode④">decode</a> algorithm. </p>
   <p><a data-link-type="dfn" href="#shared-utf-16-decoder" id="ref-for-shared-utf-16-decoder①">shared UTF-16 decoder</a> has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-16-lead-byte">UTF-16 lead byte</dfn> and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-16-lead-surrogate">UTF-16 lead surrogate</dfn> (both initially null), and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="utf-16be-decoder-flag">UTF-16BE decoder flag</dfn> (initially unset). </p>
   <p><a data-link-type="dfn" href="#shared-utf-16-decoder" id="ref-for-shared-utf-16-decoder②">shared UTF-16 decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler②①">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③⑦">end-of-stream</a> and either <a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte">UTF-16 lead byte</a> or <a data-link-type="dfn" href="#utf-16-lead-surrogate" id="ref-for-utf-16-lead-surrogate">UTF-16 lead surrogate</a> is non-null, set <a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte①">UTF-16 lead byte</a> and <a data-link-type="dfn" href="#utf-16-lead-surrogate" id="ref-for-utf-16-lead-surrogate①">UTF-16 lead surrogate</a> to null, and return <a data-link-type="dfn" href="#error" id="ref-for-error⑤④">error</a>. </p>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③⑧">end-of-stream</a> and <a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte②">UTF-16 lead byte</a> and <a data-link-type="dfn" href="#utf-16-lead-surrogate" id="ref-for-utf-16-lead-surrogate②">UTF-16 lead surrogate</a> are null, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②⑥">finished</a>. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte③">UTF-16 lead byte</a> is null, set <a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte④">UTF-16 lead byte</a> to <var>byte</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue②②">continue</a>. </p>
    <li>
     <p>Let <var>code unit</var> be the result of: </p>
     <dl class="switch">
      <dt><a data-link-type="dfn" href="#utf-16be-decoder-flag" id="ref-for-utf-16be-decoder-flag">UTF-16BE decoder flag</a> is set 
      <dd>
       <p>(<a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte⑤">UTF-16 lead byte</a> &lt;&lt; 8) + <var>byte</var>. </p>
      <dt><a data-link-type="dfn" href="#utf-16be-decoder-flag" id="ref-for-utf-16be-decoder-flag①">UTF-16BE decoder flag</a> is unset 
      <dd>
       <p>(<var>byte</var> &lt;&lt; 8) + <a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte⑥">UTF-16 lead byte</a>. </p>
     </dl>
     <p>Then set <a data-link-type="dfn" href="#utf-16-lead-byte" id="ref-for-utf-16-lead-byte⑦">UTF-16 lead byte</a> to null. </p>
    <li>
     <p>If <a data-link-type="dfn" href="#utf-16-lead-surrogate" id="ref-for-utf-16-lead-surrogate③">UTF-16 lead surrogate</a> is non-null, let <var>lead surrogate</var> be <a data-link-type="dfn" href="#utf-16-lead-surrogate" id="ref-for-utf-16-lead-surrogate④">UTF-16 lead surrogate</a>, set <a data-link-type="dfn" href="#utf-16-lead-surrogate" id="ref-for-utf-16-lead-surrogate⑤">UTF-16 lead surrogate</a> to null, and then: </p>
     <ol>
      <li>
       <p>If <var>code unit</var> is in the range U+DC00 to U+DFFF, inclusive,
   return a code point whose value is
   0x10000 + ((<var>lead surrogate</var> − 0xD800) &lt;&lt; 10) + (<var>code unit</var> − 0xDC00). </p>
      <li>
       <p>Let <var>byte1</var> be <var>code unit</var> >> 8. </p>
      <li>
       <p>Let <var>byte2</var> be <var>code unit</var> &amp; 0x00FF. </p>
      <li>
       <p>Let <var>bytes</var> be two bytes whose values are <var>byte1</var> and <var>byte2</var>,
   if the <a data-link-type="dfn" href="#utf-16be-decoder-flag" id="ref-for-utf-16be-decoder-flag②">UTF-16BE decoder flag</a> is set, and <var>byte2</var> and <var>byte1</var> otherwise. </p>
      <li>
       <p><a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend②⓪">Prepend</a> the <var>bytes</var> to <var>stream</var> and return <a data-link-type="dfn" href="#error" id="ref-for-error⑤⑤">error</a>. </p>
     </ol>
    <li>
     <p>If <var>code unit</var> is in the range U+D800 to U+DBFF, inclusive, set <a data-link-type="dfn" href="#utf-16-lead-surrogate" id="ref-for-utf-16-lead-surrogate⑥">UTF-16 lead surrogate</a> to <var>code unit</var> and return <a data-link-type="dfn" href="#continue" id="ref-for-continue②③">continue</a>. </p>
    <li>
     <p>If <var>code unit</var> is in the range U+DC00 to U+DFFF, inclusive,
 return <a data-link-type="dfn" href="#error" id="ref-for-error⑤⑥">error</a>. </p>
    <li>
     <p>Return code point <var>code unit</var>. </p>
   </ol>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="14.3" data-lt="UTF-16BE" id="utf-16be"><span class="secno">14.3. </span><span class="content">UTF-16BE</span></h3>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="14.3.1" data-lt="UTF-16BE decoder" id="utf-16be-decoder"><span class="secno">14.3.1. </span><span class="content">UTF-16BE decoder</span><a class="self-link" href="#utf-16be-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be①⓪">UTF-16BE</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder③⑨">decoder</a> is <a data-link-type="dfn" href="#shared-utf-16-decoder" id="ref-for-shared-utf-16-decoder③">shared UTF-16 decoder</a> with
its <a data-link-type="dfn" href="#utf-16be-decoder-flag" id="ref-for-utf-16be-decoder-flag③">UTF-16BE decoder flag</a> set. </p>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="14.4" data-lt="UTF-16LE" id="utf-16le"><span class="secno">14.4. </span><span class="content">UTF-16LE</span></h3>
   <p class="note no-backref" role="note">Both "<code>utf-16</code>" and
"<code>utf-16le</code>" are <a data-link-type="dfn" href="#label" id="ref-for-label①⑥">labels</a> for <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le①⓪">UTF-16LE</a> to deal with deployed content. </p>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="14.4.1" data-lt="UTF-16LE decoder" id="utf-16le-decoder"><span class="secno">14.4.1. </span><span class="content">UTF-16LE decoder</span><a class="self-link" href="#utf-16le-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le①①">UTF-16LE</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder④⓪">decoder</a> is <a data-link-type="dfn" href="#shared-utf-16-decoder" id="ref-for-shared-utf-16-decoder④">shared UTF-16 decoder</a>. </p>
   <h3 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="14.5" data-lt="x-user-defined" id="x-user-defined"><span class="secno">14.5. </span><span class="content">x-user-defined</span></h3>
   <p class="note" role="note">While technically this is a <a data-link-type="dfn" href="#single-byte-encoding" id="ref-for-single-byte-encoding⑤">single-byte encoding</a>,
it is defined separately as it can be implemented algorithmically. </p>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="14.5.1" data-lt="x-user-defined decoder" id="x-user-defined-decoder"><span class="secno">14.5.1. </span><span class="content">x-user-defined decoder</span><a class="self-link" href="#x-user-defined-decoder"></a></h4>
   <p><a data-link-type="dfn" href="#x-user-defined" id="ref-for-x-user-defined①">x-user-defined</a>’s <a data-link-type="dfn" href="#decoder" id="ref-for-decoder④①">decoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler②②">handler</a>, given a <var>stream</var> and <var>byte</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>byte</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream③⑨">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②⑦">finished</a>. </p>
    <li>
     <p>If <var>byte</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte①②">ASCII byte</a>, return
 a code point whose value is <var>byte</var>. </p>
    <li>
     <p>Return a code point whose value is 0xF780 + <var>byte</var> − 0x80. </p>
   </ol>
   <h4 class="heading settled" data-dfn-type="dfn" data-export data-level="14.5.2" data-lt="x-user-defined encoder" id="x-user-defined-encoder"><span class="secno">14.5.2. </span><span class="content">x-user-defined encoder</span><a class="self-link" href="#x-user-defined-encoder"></a></h4>
   <p><a data-link-type="dfn" href="#x-user-defined" id="ref-for-x-user-defined②">x-user-defined</a>’s <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②⑧">encoder</a>’s <a data-link-type="dfn" href="#handler" id="ref-for-handler②③">handler</a>, given a <var>stream</var> and <var>code point</var>, runs these steps: </p>
   <ol>
    <li>
     <p>If <var>code point</var> is <a data-link-type="dfn" href="#end-of-stream" id="ref-for-end-of-stream④⓪">end-of-stream</a>, return <a data-link-type="dfn" href="#finished" id="ref-for-finished②⑧">finished</a>. </p>
    <li>
     <p>If <var>code point</var> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-code-point" id="ref-for-ascii-code-point①②">ASCII code point</a>, return
 a byte whose value is <var>code point</var>. </p>
    <li>
     <p>If <var>code point</var> is in the range U+F780 to U+F7FF, inclusive, return
 a byte whose value is <var>code point</var> − 0xF780 + 0x80. </p>
    <li>
     <p>Return <a data-link-type="dfn" href="#error" id="ref-for-error⑤⑦">error</a> with <var>code point</var>. </p>
   </ol>
   <h2 class="heading settled" data-level="15" id="browser-ui"><span class="secno">15. </span><span class="content">Browser UI</span><a class="self-link" href="#browser-ui"></a></h2>
   <p>Browsers are encouraged to not enable overriding the encoding of a resource. If such a
feature is nonetheless present, browsers should not offer either <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be①①">UTF-16BE</a> or <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le①②">UTF-16LE</a> as option due to aforementioned security
issues. Browsers also should disable this feature if the resource was decoded using either <a data-link-type="dfn" href="#utf-16be" id="ref-for-utf-16be①②">UTF-16BE</a> or <a data-link-type="dfn" href="#utf-16le" id="ref-for-utf-16le①③">UTF-16LE</a>. </p>
   <h2 class="no-num heading settled" id="implementation-considerations"><span class="content">Implementation considerations</span><a class="self-link" href="#implementation-considerations"></a></h2>
   <p>Instead of supporting <a data-link-type="dfn" href="#concept-stream" id="ref-for-concept-stream②⑤">streams</a> with arbitrary <a data-link-type="dfn" href="#concept-stream-prepend" id="ref-for-concept-stream-prepend②①">prepend</a>, the <a data-link-type="dfn" href="#decoder" id="ref-for-decoder④②">decoders</a> for <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②⑥">encodings</a> in this standard could be implemented with: </p>
   <ol>
    <li>
     <p>The ability to unread the current byte. </p>
    <li>
     <p>A single-byte buffer for <a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030⑧">gb18030</a> (an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ascii-byte" id="ref-for-ascii-byte①③">ASCII byte</a>) and <a data-link-type="dfn" href="#iso-2022-jp" id="ref-for-iso-2022-jp⑥">ISO-2022-JP</a> (0x24 or
  0x28). </p>
     <p class="example" id="example-gb18030-implementation-strategy"><a class="self-link" href="#example-gb18030-implementation-strategy"></a>For <a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030⑨">gb18030</a> when hitting a
  bogus byte while <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third⑨">gb18030 third</a> is not 0x00, <a data-link-type="dfn" href="#gb18030-second" id="ref-for-gb18030-second①①">gb18030 second</a> could be moved into the
  single-byte buffer to be returned next, and <a data-link-type="dfn" href="#gb18030-third" id="ref-for-gb18030-third①⓪">gb18030 third</a> would be the new <a data-link-type="dfn" href="#gb18030-first" id="ref-for-gb18030-first①①">gb18030 first</a>, checked for not being 0x00 after the single-byte buffer was returned and
  emptied. This is possible as the range for the first and third byte in <a data-link-type="dfn" href="#gb18030" id="ref-for-gb18030①⓪">gb18030</a> is
  identical. </p>
   </ol>
   <p>The <a data-link-type="dfn" href="#iso-2022-jp-encoder" id="ref-for-iso-2022-jp-encoder②">ISO-2022-JP encoder</a> needs <a data-link-type="dfn" href="#iso-2022-jp-encoder-state" id="ref-for-iso-2022-jp-encoder-state①②">ISO-2022-JP encoder state</a> as additional state, but
other than that, none of the <a data-link-type="dfn" href="#encoder" id="ref-for-encoder②⑨">encoders</a> for <a data-link-type="dfn" href="#encoding" id="ref-for-encoding②⑦">encodings</a> in this standard
require additional state or buffers. </p>
   <h2 class="no-num heading settled" id="acknowledgments"><span class="content">Acknowledgments</span><a class="self-link" href="#acknowledgments"></a></h2>
   <p>There have been a lot of people that have helped make encodings more
interoperable over the years and thereby furthered the goals of this
standard. Likewise many people have helped making this standard what it is
today. </p>
   <p>With that, many thanks to
Adam Rice,
Alan Chaney,
Alexander Shtuchkin,
Allen Wirfs-Brock,
Aneesh Agrawal,
Arkadiusz Michalski,
Asmus Freytag,
Ben Noordhuis,
Bnaya Peretz,
Boris Zbarsky,
Bruno Haible,
Cameron McCormack,
Charles McCathieNeville,
Christopher Foo,
David Carlisle,
Domenic Denicola,
Dominique Hazaël-Massieux,
Doug Ewell,
Erik van der Poel,
譚永鋒 (Frank Yung-Fong Tang),
Glenn Maynard,
Gordon P. Hemsley,
Henri Sivonen,
Ian Hickson,
James Graham,
Jeffrey Yasskin,
John Tamplin,
Joshua Bell,
村井純 (Jun Murai),
신정식 (Jungshik Shin),
Jxck,
강 성훈 (Kang Seonghoon),
川幡太一 (Kawabata Taichi),
Ken Lunde,
Ken Whistler,
Kenneth Russell,
田村健人 (Kent Tamura),
Leif Halvard Silli,
Luke Wagner,
Maciej Hirsz,
Makoto Kato,
Mark Callow,
Mark Crispin,
Mark Davis,
Martin Dürst,
Masatoshi Kimura,
Mattias Buelens,
Ms2ger,
Nigel Megitt,
Nigel Tao,
Norbert Lindenberg,
Øistein E. Andersen,
Peter Krefting,
Philip Jägenstedt,
Philip Taylor,
Richard Ishida,
Robbert Broersma,
Robert Mustacchi,
Ryan Dahl,
Sam Sneddon,
Shawn Steele,
Simon Montagu,
Simon Pieters,
Simon Sapin,
寺田健 (Takeshi Terada),
Vyacheslav Matva, and
成瀬ゆい (Yui Naruse)
for being awesome. </p>
   <p>This standard is written by <a href="https://annevankesteren.nl/" lang="nl">Anne van Kesteren</a> (<a href="https://www.mozilla.org/">Mozilla</a>, <a href="mailto:annevk@annevk.nl">annevk@annevk.nl</a>). The <a href="#api">API</a> chapter
was initially written by Joshua Bell (<a href="https://www.google.com/">Google</a>). </p>
   <p>Copyright © 1970 WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a <a href="https://creativecommons.org/licenses/by/4.0/" rel="license">Creative Commons Attribution
4.0 International License</a>. </p>
  </main>
<script>
"use strict";
if ("serviceWorker" in navigator) {
  navigator.serviceWorker.register("/service-worker.js");
}
</script>
  <h2 class="no-num no-ref heading settled" id="section-index"><span class="content">Index</span><a class="self-link" href="#section-index"></a></h2>
  <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3>
  <ul class="index">
   <li><a href="#big5">Big5</a><span>, in §11</span>
   <li><a href="#big5-decoder">Big5 decoder</a><span>, in §11.1</span>
   <li><a href="#big5-encoder">Big5 encoder</a><span>, in §11.1.1</span>
   <li><a href="#big5-lead">Big5 lead</a><span>, in §11.1.1</span>
   <li><a href="#textdecoder-bom-seen-flag">BOM seen flag</a><span>, in §7.1</span>
   <li>
    constructor()
    <ul>
     <li><a href="#dom-textdecoder">constructor for TextDecoder</a><span>, in §7.2</span>
     <li><a href="#dom-textdecoderstream">constructor for TextDecoderStream</a><span>, in §7.6</span>
     <li><a href="#dom-textencoder">constructor for TextEncoder</a><span>, in §7.4</span>
     <li><a href="#dom-textencoderstream">constructor for TextEncoderStream</a><span>, in §7.7</span>
    </ul>
   <li>
    constructor(label)
    <ul>
     <li><a href="#dom-textdecoder">constructor for TextDecoder</a><span>, in §7.2</span>
     <li><a href="#dom-textdecoderstream">constructor for TextDecoderStream</a><span>, in §7.6</span>
    </ul>
   <li>
    constructor(label, options)
    <ul>
     <li><a href="#dom-textdecoder">constructor for TextDecoder</a><span>, in §7.2</span>
     <li><a href="#dom-textdecoderstream">constructor for TextDecoderStream</a><span>, in §7.6</span>
    </ul>
   <li><a href="#continue">continue</a><span>, in §4.1</span>
   <li><a href="#convert-code-unit-to-scalar-value">convert code unit to scalar value</a><span>, in §7.7</span>
   <li><a href="#decode">decode</a><span>, in §6</span>
   <li><a href="#dom-textdecoder-decode">decode()</a><span>, in §7.2</span>
   <li><a href="#decode-and-enqueue-a-chunk">decode and enqueue a chunk</a><span>, in §7.6</span>
   <li><a href="#dom-textdecoder-decode">decode(input)</a><span>, in §7.2</span>
   <li><a href="#dom-textdecoder-decode">decode(input, options)</a><span>, in §7.2</span>
   <li>
    decoder
    <ul>
     <li><a href="#decoder">definition of</a><span>, in §4.1</span>
     <li><a href="#textdecoder-decoder">dfn for TextDecoder</a><span>, in §7.2</span>
     <li><a href="#textdecoderstream-decoder">dfn for TextDecoderStream</a><span>, in §7.6</span>
    </ul>
   <li><a href="#textdecoder-do-not-flush-flag">do not flush flag</a><span>, in §7.2</span>
   <li><a href="#encode">encode</a><span>, in §6</span>
   <li><a href="#dom-textencoder-encode">encode()</a><span>, in §7.4</span>
   <li><a href="#encode-and-enqueue-a-chunk">encode and enqueue a chunk</a><span>, in §7.7</span>
   <li><a href="#encode-and-flush">encode and flush</a><span>, in §7.7</span>
   <li><a href="#dom-textencoder-encode">encode(input)</a><span>, in §7.4</span>
   <li><a href="#dom-textencoder-encodeinto">encodeInto(source, destination)</a><span>, in §7.4</span>
   <li>
    encoder
    <ul>
     <li><a href="#encoder">definition of</a><span>, in §4.1</span>
     <li><a href="#textencoderstream-encoder">dfn for TextEncoderStream</a><span>, in §7.7</span>
    </ul>
   <li>
    encoding
    <ul>
     <li><a href="#dom-textdecoder-encoding">attribute for TextDecoderCommon</a><span>, in §7.1</span>
     <li><a href="#dom-textencoder-encoding">attribute for TextEncoderCommon</a><span>, in §7.3</span>
     <li><a href="#encoding">definition of</a><span>, in §4</span>
     <li><a href="#textdecoder-encoding">dfn for TextDecoderCommon</a><span>, in §7.1</span>
    </ul>
   <li><a href="#end-of-stream">End-of-stream</a><span>, in §3</span>
   <li><a href="#error">error</a><span>, in §4.1</span>
   <li>
    error mode
    <ul>
     <li><a href="#error-mode">definition of</a><span>, in §4.1</span>
     <li><a href="#textdecoder-error-mode">dfn for TextDecoderCommon</a><span>, in §7.1</span>
    </ul>
   <li><a href="#euc-jp">EUC-JP</a><span>, in §12</span>
   <li><a href="#euc-jp-decoder">EUC-JP decoder</a><span>, in §12.1</span>
   <li><a href="#euc-jp-encoder">EUC-JP encoder</a><span>, in §12.1.1</span>
   <li><a href="#euc-jp-jis0212-flag">EUC-JP jis0212 flag</a><span>, in §12.1.1</span>
   <li><a href="#euc-jp-lead">EUC-JP lead</a><span>, in §12.1.1</span>
   <li><a href="#euc-kr">EUC-KR</a><span>, in §13</span>
   <li><a href="#euc-kr-decoder">EUC-KR decoder</a><span>, in §13.1</span>
   <li><a href="#euc-kr-encoder">EUC-KR encoder</a><span>, in §13.1.1</span>
   <li><a href="#euc-kr-lead">EUC-KR lead</a><span>, in §13.1.1</span>
   <li>
    fatal
    <ul>
     <li><a href="#dom-textdecoder-fatal">attribute for TextDecoderCommon</a><span>, in §7.1</span>
     <li><a href="#dom-textdecoderoptions-fatal">dict-member for TextDecoderOptions</a><span>, in §7.2</span>
    </ul>
   <li><a href="#finished">finished</a><span>, in §4.1</span>
   <li><a href="#flush-and-enqueue">flush and enqueue</a><span>, in §7.6</span>
   <li><a href="#gb18030">gb18030</a><span>, in §10.1.2</span>
   <li><a href="#gb18030-decoder">gb18030 decoder</a><span>, in §10.2</span>
   <li><a href="#gb18030-encoder">gb18030 encoder</a><span>, in §10.2.1</span>
   <li><a href="#gb18030-first">gb18030 first</a><span>, in §10.2.1</span>
   <li><a href="#gb18030-second">gb18030 second</a><span>, in §10.2.1</span>
   <li><a href="#gb18030-third">gb18030 third</a><span>, in §10.2.1</span>
   <li><a href="#gbk">GBK</a><span>, in §10</span>
   <li><a href="#gbk-decoder">GBK decoder</a><span>, in §10.1</span>
   <li><a href="#gbk-encoder">GBK encoder</a><span>, in §10.1.1</span>
   <li><a href="#gbk-flag">GBK flag</a><span>, in §10.2.2</span>
   <li><a href="#generictransformstream">GenericTransformStream</a><span>, in §7.5</span>
   <li><a href="#concept-encoding-get">get an encoding</a><span>, in §4.2</span>
   <li><a href="#get-an-output-encoding">get an output encoding</a><span>, in §4.3</span>
   <li><a href="#concept-encoding-get">getting an encoding</a><span>, in §4.2</span>
   <li><a href="#handler">handler</a><span>, in §4.1</span>
   <li><a href="#ibm866">IBM866</a><span>, in §9</span>
   <li>
    ignoreBOM
    <ul>
     <li><a href="#dom-textdecoder-ignorebom">attribute for TextDecoderCommon</a><span>, in §7.1</span>
     <li><a href="#dom-textdecoderoptions-ignorebom">dict-member for TextDecoderOptions</a><span>, in §7.2</span>
    </ul>
   <li><a href="#textdecoder-ignore-bom-flag">ignore BOM flag</a><span>, in §7.1</span>
   <li><a href="#index">index</a><span>, in §5</span>
   <li><a href="#index-big5">index Big5</a><span>, in §5</span>
   <li><a href="#index-big5-pointer">index Big5 pointer</a><span>, in §5</span>
   <li><a href="#index-code-point">index code point</a><span>, in §5</span>
   <li><a href="#index-euc-kr">index EUC-KR</a><span>, in §5</span>
   <li><a href="#index-gb18030">index gb18030</a><span>, in §5</span>
   <li><a href="#index-gb18030-ranges">index gb18030 ranges</a><span>, in §5</span>
   <li><a href="#index-gb18030-ranges-code-point">index gb18030 ranges code point</a><span>, in §5</span>
   <li><a href="#index-gb18030-ranges-pointer">index gb18030 ranges pointer</a><span>, in §5</span>
   <li><a href="#index-iso-2022-jp-katakana">index ISO-2022-JP katakana</a><span>, in §5</span>
   <li><a href="#index-jis0208">index jis0208</a><span>, in §5</span>
   <li><a href="#index-jis0212">index jis0212</a><span>, in §5</span>
   <li><a href="#index-pointer">index pointer</a><span>, in §5</span>
   <li><a href="#index-shift_jis-pointer">index Shift_JIS pointer</a><span>, in §5</span>
   <li><a href="#index-single-byte">Index single-byte</a><span>, in §9</span>
   <li><a href="#iso-2022-jp">ISO-2022-JP</a><span>, in §12.1.2</span>
   <li><a href="#iso-2022-jp-decoder">ISO-2022-JP decoder</a><span>, in §12.2</span>
   <li><a href="#iso-2022-jp-decoder-ascii">ISO-2022-JP decoder ASCII</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-escape">ISO-2022-JP decoder escape</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-escape-start">ISO-2022-JP decoder escape start</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-katakana">ISO-2022-JP decoder katakana</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-lead-byte">ISO-2022-JP decoder lead byte</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-output-state">ISO-2022-JP decoder output state</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-roman">ISO-2022-JP decoder Roman</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-state">ISO-2022-JP decoder state</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-decoder-trail-byte">ISO-2022-JP decoder trail byte</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-encoder">ISO-2022-JP encoder</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-encoder-ascii">ISO-2022-JP encoder ASCII</a><span>, in §12.2.2</span>
   <li><a href="#iso-2022-jp-encoder-jis0208">ISO-2022-JP encoder jis0208</a><span>, in §12.2.2</span>
   <li><a href="#iso-2022-jp-encoder-roman">ISO-2022-JP encoder Roman</a><span>, in §12.2.2</span>
   <li><a href="#iso-2022-jp-encoder-state">ISO-2022-JP encoder state</a><span>, in §12.2.2</span>
   <li><a href="#iso-2022-jp-lead">ISO-2022-JP lead</a><span>, in §12.2.1</span>
   <li><a href="#iso-2022-jp-output-flag">ISO-2022-JP output flag</a><span>, in §12.2.1</span>
   <li><a href="#iso-8859-10">ISO-8859-10</a><span>, in §9</span>
   <li><a href="#iso-8859-13">ISO-8859-13</a><span>, in §9</span>
   <li><a href="#iso-8859-14">ISO-8859-14</a><span>, in §9</span>
   <li><a href="#iso-8859-15">ISO-8859-15</a><span>, in §9</span>
   <li><a href="#iso-8859-16">ISO-8859-16</a><span>, in §9</span>
   <li><a href="#iso-8859-2">ISO-8859-2</a><span>, in §9</span>
   <li><a href="#iso-8859-3">ISO-8859-3</a><span>, in §9</span>
   <li><a href="#iso-8859-4">ISO-8859-4</a><span>, in §9</span>
   <li><a href="#iso-8859-5">ISO-8859-5</a><span>, in §9</span>
   <li><a href="#iso-8859-6">ISO-8859-6</a><span>, in §9</span>
   <li><a href="#iso-8859-7">ISO-8859-7</a><span>, in §9</span>
   <li><a href="#iso-8859-8">ISO-8859-8</a><span>, in §9</span>
   <li><a href="#iso-8859-8-i">ISO-8859-8-I</a><span>, in §9</span>
   <li><a href="#koi8-r">KOI8-R</a><span>, in §9</span>
   <li><a href="#koi8-u">KOI8-U</a><span>, in §9</span>
   <li><a href="#label">label</a><span>, in §4</span>
   <li><a href="#macintosh">macintosh</a><span>, in §9</span>
   <li><a href="#name">name</a><span>, in §4</span>
   <li><a href="#textencoderstream-pending-high-surrogate">pending high surrogate</a><span>, in §7.7</span>
   <li><a href="#concept-stream-prepend">prepended</a><span>, in §3</span>
   <li><a href="#concept-encoding-process">process</a><span>, in §4.1</span>
   <li><a href="#concept-stream-push">pushed</a><span>, in §3</span>
   <li>
    read
    <ul>
     <li><a href="#concept-stream-read">dfn for stream</a><span>, in §3</span>
     <li><a href="#dom-textencoderencodeintoresult-read">dict-member for TextEncoderEncodeIntoResult</a><span>, in §7.4</span>
    </ul>
   <li><a href="#dom-generictransformstream-readable">readable</a><span>, in §7.5</span>
   <li><a href="#replacement">replacement</a><span>, in §14</span>
   <li><a href="#replacement-decoder">replacement decoder</a><span>, in §14.1</span>
   <li><a href="#replacement-error-returned-flag">replacement error returned flag</a><span>, in §14.1.1</span>
   <li><a href="#concept-encoding-run">run</a><span>, in §4.1</span>
   <li><a href="#concept-td-serialize">serialize stream</a><span>, in §7.1</span>
   <li><a href="#shared-utf-16-decoder">shared UTF-16 decoder</a><span>, in §14.2</span>
   <li><a href="#shift_jis">Shift_JIS</a><span>, in §12.2.2</span>
   <li><a href="#shift_jis-decoder">Shift_JIS decoder</a><span>, in §12.3</span>
   <li><a href="#shift_jis-encoder">Shift_JIS encoder</a><span>, in §12.3.1</span>
   <li><a href="#shift_jis-lead">Shift_JIS lead</a><span>, in §12.3.1</span>
   <li><a href="#single-byte-decoder">single-byte decoder</a><span>, in §9</span>
   <li><a href="#single-byte-encoder">single-byte encoder</a><span>, in §9.1</span>
   <li><a href="#single-byte-encoding">single-byte encoding</a><span>, in §9</span>
   <li>
    stream
    <ul>
     <li><a href="#concept-stream">definition of</a><span>, in §3</span>
     <li><a href="#textdecoder-stream">dfn for TextDecoder</a><span>, in §7.2</span>
     <li><a href="#textdecoderstream-stream">dfn for TextDecoderStream</a><span>, in §7.6</span>
     <li><a href="#dom-textdecodeoptions-stream">dict-member for TextDecodeOptions</a><span>, in §7.2</span>
    </ul>
   <li><a href="#textdecodeoptions">TextDecodeOptions</a><span>, in §7.2</span>
   <li><a href="#dom-textdecoder">TextDecoder()</a><span>, in §7.2</span>
   <li><a href="#textdecoder">TextDecoder</a><span>, in §7.2</span>
   <li><a href="#textdecodercommon">TextDecoderCommon</a><span>, in §7.1</span>
   <li><a href="#dom-textdecoder">TextDecoder(label)</a><span>, in §7.2</span>
   <li><a href="#dom-textdecoder">TextDecoder(label, options)</a><span>, in §7.2</span>
   <li><a href="#textdecoderoptions">TextDecoderOptions</a><span>, in §7.2</span>
   <li><a href="#dom-textdecoderstream">TextDecoderStream()</a><span>, in §7.6</span>
   <li><a href="#textdecoderstream">TextDecoderStream</a><span>, in §7.6</span>
   <li><a href="#dom-textdecoderstream">TextDecoderStream(label)</a><span>, in §7.6</span>
   <li><a href="#dom-textdecoderstream">TextDecoderStream(label, options)</a><span>, in §7.6</span>
   <li><a href="#textencoder">TextEncoder</a><span>, in §7.4</span>
   <li><a href="#dom-textencoder">TextEncoder()</a><span>, in §7.4</span>
   <li><a href="#textencodercommon">TextEncoderCommon</a><span>, in §7.3</span>
   <li><a href="#dictdef-textencoderencodeintoresult">TextEncoderEncodeIntoResult</a><span>, in §7.4</span>
   <li><a href="#dom-textencoderstream">TextEncoderStream()</a><span>, in §7.7</span>
   <li><a href="#textencoderstream">TextEncoderStream</a><span>, in §7.7</span>
   <li><a href="#concept-token">token</a><span>, in §3</span>
   <li><a href="#generictransformstream-transform">transform</a><span>, in §7.5</span>
   <li><a href="#utf-16be">UTF-16BE</a><span>, in §14.2.1</span>
   <li><a href="#utf-16be-decoder">UTF-16BE decoder</a><span>, in §14.3</span>
   <li><a href="#utf-16be-decoder-flag">UTF-16BE decoder flag</a><span>, in §14.2.1</span>
   <li><a href="#utf-16le">UTF-16LE</a><span>, in §14.3.1</span>
   <li><a href="#utf-16-lead-byte">UTF-16 lead byte</a><span>, in §14.2.1</span>
   <li><a href="#utf-16-lead-surrogate">UTF-16 lead surrogate</a><span>, in §14.2.1</span>
   <li><a href="#utf-16le-decoder">UTF-16LE decoder</a><span>, in §14.4</span>
   <li><a href="#utf-8">UTF-8</a><span>, in §8</span>
   <li><a href="#utf-8-bytes-needed">UTF-8 bytes needed</a><span>, in §8.1.1</span>
   <li><a href="#utf-8-bytes-seen">UTF-8 bytes seen</a><span>, in §8.1.1</span>
   <li><a href="#utf-8-code-point">UTF-8 code point</a><span>, in §8.1.1</span>
   <li><a href="#utf-8-decode">UTF-8 decode</a><span>, in §6</span>
   <li><a href="#utf-8-decoder">UTF-8 decoder</a><span>, in §8.1</span>
   <li><a href="#utf-8-decode-without-bom">UTF-8 decode without BOM</a><span>, in §6</span>
   <li><a href="#utf-8-decode-without-bom-or-fail">UTF-8 decode without BOM or fail</a><span>, in §6</span>
   <li><a href="#utf-8-encode">UTF-8 encode</a><span>, in §6</span>
   <li><a href="#utf-8-encoder">UTF-8 encoder</a><span>, in §8.1.1</span>
   <li><a href="#utf-8-lower-boundary">UTF-8 lower boundary</a><span>, in §8.1.1</span>
   <li><a href="#utf-8-upper-boundary">UTF-8 upper boundary</a><span>, in §8.1.1</span>
   <li><a href="#windows-1250">windows-1250</a><span>, in §9</span>
   <li><a href="#windows-1251">windows-1251</a><span>, in §9</span>
   <li><a href="#windows-1252">windows-1252</a><span>, in §9</span>
   <li><a href="#windows-1253">windows-1253</a><span>, in §9</span>
   <li><a href="#windows-1254">windows-1254</a><span>, in §9</span>
   <li><a href="#windows-1255">windows-1255</a><span>, in §9</span>
   <li><a href="#windows-1256">windows-1256</a><span>, in §9</span>
   <li><a href="#windows-1257">windows-1257</a><span>, in §9</span>
   <li><a href="#windows-1258">windows-1258</a><span>, in §9</span>
   <li><a href="#windows-874">windows-874</a><span>, in §9</span>
   <li><a href="#dom-generictransformstream-writable">writable</a><span>, in §7.5</span>
   <li><a href="#dom-textencoderencodeintoresult-written">written</a><span>, in §7.4</span>
   <li><a href="#x-mac-cyrillic">x-mac-cyrillic</a><span>, in §9</span>
   <li><a href="#x-user-defined">x-user-defined</a><span>, in §14.4.1</span>
   <li><a href="#x-user-defined-decoder">x-user-defined decoder</a><span>, in §14.5</span>
   <li><a href="#x-user-defined-encoder">x-user-defined encoder</a><span>, in §14.5.1</span>
  </ul>
  <aside class="dfn-panel" data-for="term-for-ascii-byte">
   <a href="https://infra.spec.whatwg.org/#ascii-byte">https://infra.spec.whatwg.org/#ascii-byte</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ascii-byte">2. Security background</a>
    <li><a href="#ref-for-ascii-byte①">9.1. single-byte decoder</a>
    <li><a href="#ref-for-ascii-byte②">10.2.1. gb18030 decoder</a> <a href="#ref-for-ascii-byte③">(2)</a>
    <li><a href="#ref-for-ascii-byte④">11.1.1. Big5 decoder</a> <a href="#ref-for-ascii-byte⑤">(2)</a>
    <li><a href="#ref-for-ascii-byte⑥">12.1.1. EUC-JP decoder</a> <a href="#ref-for-ascii-byte⑦">(2)</a>
    <li><a href="#ref-for-ascii-byte⑧">12.3.1. Shift_JIS decoder</a> <a href="#ref-for-ascii-byte⑨">(2)</a>
    <li><a href="#ref-for-ascii-byte①⓪">13.1.1. EUC-KR decoder</a> <a href="#ref-for-ascii-byte①①">(2)</a>
    <li><a href="#ref-for-ascii-byte①②">14.5.1. x-user-defined decoder</a>
    <li><a href="#ref-for-ascii-byte①③">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ascii-case-insensitive">
   <a href="https://infra.spec.whatwg.org/#ascii-case-insensitive">https://infra.spec.whatwg.org/#ascii-case-insensitive</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ascii-case-insensitive">4.2. Names and labels</a> <a href="#ref-for-ascii-case-insensitive①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ascii-code-point">
   <a href="https://infra.spec.whatwg.org/#ascii-code-point">https://infra.spec.whatwg.org/#ascii-code-point</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ascii-code-point">2. Security background</a>
    <li><a href="#ref-for-ascii-code-point①">8.1.2. UTF-8 encoder</a>
    <li><a href="#ref-for-ascii-code-point②">9.2. single-byte encoder</a>
    <li><a href="#ref-for-ascii-code-point③">10.2.2. gb18030 encoder</a>
    <li><a href="#ref-for-ascii-code-point④">11.1.2. Big5 encoder</a>
    <li><a href="#ref-for-ascii-code-point⑤">12.1.2. EUC-JP encoder</a>
    <li><a href="#ref-for-ascii-code-point⑥">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-ascii-code-point⑦">(2)</a> <a href="#ref-for-ascii-code-point⑧">(3)</a> <a href="#ref-for-ascii-code-point⑨">(4)</a>
    <li><a href="#ref-for-ascii-code-point①⓪">12.3.2. Shift_JIS encoder</a>
    <li><a href="#ref-for-ascii-code-point①①">13.1.2. EUC-KR encoder</a>
    <li><a href="#ref-for-ascii-code-point①②">14.5.2. x-user-defined encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ascii-digit">
   <a href="https://infra.spec.whatwg.org/#ascii-digit">https://infra.spec.whatwg.org/#ascii-digit</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ascii-digit">4.1. Encoders and decoders</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ascii-lowercase">
   <a href="https://infra.spec.whatwg.org/#ascii-lowercase">https://infra.spec.whatwg.org/#ascii-lowercase</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ascii-lowercase">4.2. Names and labels</a>
    <li><a href="#ref-for-ascii-lowercase①">7.1. Interface mixin TextDecoderCommon</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ascii-whitespace">
   <a href="https://infra.spec.whatwg.org/#ascii-whitespace">https://infra.spec.whatwg.org/#ascii-whitespace</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ascii-whitespace">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-iteration-break">
   <a href="https://infra.spec.whatwg.org/#iteration-break">https://infra.spec.whatwg.org/#iteration-break</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iteration-break">7.4. Interface TextEncoder</a> <a href="#ref-for-iteration-break①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-byte">
   <a href="https://infra.spec.whatwg.org/#byte">https://infra.spec.whatwg.org/#byte</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-byte">3. Terminology</a>
    <li><a href="#ref-for-byte①">4. Encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-code-point">
   <a href="https://infra.spec.whatwg.org/#code-point">https://infra.spec.whatwg.org/#code-point</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-code-point">3. Terminology</a>
    <li><a href="#ref-for-code-point①">4.1. Encoders and decoders</a> <a href="#ref-for-code-point②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-code-unit">
   <a href="https://infra.spec.whatwg.org/#code-unit">https://infra.spec.whatwg.org/#code-unit</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-code-unit">7.4. Interface TextEncoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-javascript-string-convert">
   <a href="https://infra.spec.whatwg.org/#javascript-string-convert">https://infra.spec.whatwg.org/#javascript-string-convert</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-javascript-string-convert">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-javascript-string">
   <a href="https://infra.spec.whatwg.org/#javascript-string">https://infra.spec.whatwg.org/#javascript-string</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-javascript-string">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-byte-sequence-length">
   <a href="https://infra.spec.whatwg.org/#byte-sequence-length">https://infra.spec.whatwg.org/#byte-sequence-length</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-byte-sequence-length">7.4. Interface TextEncoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-scalar-value">
   <a href="https://infra.spec.whatwg.org/#scalar-value">https://infra.spec.whatwg.org/#scalar-value</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-scalar-value">4. Encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-scalar-value-string">
   <a href="https://infra.spec.whatwg.org/#scalar-value-string">https://infra.spec.whatwg.org/#scalar-value-string</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-scalar-value-string">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-create-transform-stream">
   <a href="https://streams.spec.whatwg.org/#create-transform-stream">https://streams.spec.whatwg.org/#create-transform-stream</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-create-transform-stream">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-create-transform-stream①">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-rs-class">
   <a href="https://streams.spec.whatwg.org/#rs-class">https://streams.spec.whatwg.org/#rs-class</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-rs-class">7.5. Interface mixin GenericTransformStream</a>
    <li><a href="#ref-for-rs-class①">7.6. Interface TextDecoderStream</a> <a href="#ref-for-rs-class②">(2)</a>
    <li><a href="#ref-for-rs-class③">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ts-class">
   <a href="https://streams.spec.whatwg.org/#ts-class">https://streams.spec.whatwg.org/#ts-class</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ts-class">7.5. Interface mixin GenericTransformStream</a> <a href="#ref-for-ts-class①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-transform-stream-default-controller-enqueue">
   <a href="https://streams.spec.whatwg.org/#transform-stream-default-controller-enqueue">https://streams.spec.whatwg.org/#transform-stream-default-controller-enqueue</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-transform-stream-default-controller-enqueue">7.6. Interface TextDecoderStream</a> <a href="#ref-for-transform-stream-default-controller-enqueue①">(2)</a>
    <li><a href="#ref-for-transform-stream-default-controller-enqueue②">7.7. Interface TextEncoderStream</a> <a href="#ref-for-transform-stream-default-controller-enqueue③">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-ws-class">
   <a href="https://streams.spec.whatwg.org/#ws-class">https://streams.spec.whatwg.org/#ws-class</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ws-class">7.5. Interface mixin GenericTransformStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-chunk">
   <a href="https://streams.spec.whatwg.org/#chunk">https://streams.spec.whatwg.org/#chunk</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-chunk">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-chunk①">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-rs-pipe-through">
   <a href="https://streams.spec.whatwg.org/#rs-pipe-through">https://streams.spec.whatwg.org/#rs-pipe-through</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-rs-pipe-through">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-rs-pipe-through①">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-readable-stream">
   <a href="https://streams.spec.whatwg.org/#readable-stream">https://streams.spec.whatwg.org/#readable-stream</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-readable-stream">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-readable-stream①">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-transform-stream">
   <a href="https://streams.spec.whatwg.org/#transform-stream">https://streams.spec.whatwg.org/#transform-stream</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-transform-stream">7.5. Interface mixin GenericTransformStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-writable-stream">
   <a href="https://streams.spec.whatwg.org/#writable-stream">https://streams.spec.whatwg.org/#writable-stream</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-writable-stream">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-writable-stream①">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-AllowShared">
   <a href="https://heycam.github.io/webidl/#AllowShared">https://heycam.github.io/webidl/#AllowShared</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-AllowShared">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-AllowShared①">7.4. Interface TextEncoder</a>
    <li><a href="#ref-for-AllowShared②">7.6. Interface TextDecoderStream</a> <a href="#ref-for-AllowShared③">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-idl-ArrayBuffer">
   <a href="https://heycam.github.io/webidl/#idl-ArrayBuffer">https://heycam.github.io/webidl/#idl-ArrayBuffer</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-idl-ArrayBuffer">7. API</a> <a href="#ref-for-idl-ArrayBuffer①">(2)</a>
    <li><a href="#ref-for-idl-ArrayBuffer②">7.4. Interface TextEncoder</a> <a href="#ref-for-idl-ArrayBuffer③">(2)</a>
    <li><a href="#ref-for-idl-ArrayBuffer④">7.7. Interface TextEncoderStream</a> <a href="#ref-for-idl-ArrayBuffer⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-BufferSource">
   <a href="https://heycam.github.io/webidl/#BufferSource">https://heycam.github.io/webidl/#BufferSource</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-BufferSource">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-BufferSource①">7.6. Interface TextDecoderStream</a> <a href="#ref-for-BufferSource②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-idl-DOMString">
   <a href="https://heycam.github.io/webidl/#idl-DOMString">https://heycam.github.io/webidl/#idl-DOMString</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-idl-DOMString">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-idl-DOMString①">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-idl-DOMString②">7.3. Interface mixin TextEncoderCommon</a>
    <li><a href="#ref-for-idl-DOMString③">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-idl-DOMString④">7.7. Interface TextEncoderStream</a> <a href="#ref-for-idl-DOMString⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-Exposed">
   <a href="https://heycam.github.io/webidl/#Exposed">https://heycam.github.io/webidl/#Exposed</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-Exposed">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-Exposed①">7.4. Interface TextEncoder</a>
    <li><a href="#ref-for-Exposed②">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-Exposed③">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-NewObject">
   <a href="https://heycam.github.io/webidl/#NewObject">https://heycam.github.io/webidl/#NewObject</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-NewObject">7.4. Interface TextEncoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-exceptiondef-rangeerror">
   <a href="https://heycam.github.io/webidl/#exceptiondef-rangeerror">https://heycam.github.io/webidl/#exceptiondef-rangeerror</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-exceptiondef-rangeerror">7.2. Interface TextDecoder</a> <a href="#ref-for-exceptiondef-rangeerror①">(2)</a>
    <li><a href="#ref-for-exceptiondef-rangeerror②">7.6. Interface TextDecoderStream</a> <a href="#ref-for-exceptiondef-rangeerror③">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-exceptiondef-typeerror">
   <a href="https://heycam.github.io/webidl/#exceptiondef-typeerror">https://heycam.github.io/webidl/#exceptiondef-typeerror</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-exceptiondef-typeerror">7.2. Interface TextDecoder</a> <a href="#ref-for-exceptiondef-typeerror①">(2)</a>
    <li><a href="#ref-for-exceptiondef-typeerror②">7.6. Interface TextDecoderStream</a> <a href="#ref-for-exceptiondef-typeerror③">(2)</a> <a href="#ref-for-exceptiondef-typeerror④">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-idl-USVString">
   <a href="https://heycam.github.io/webidl/#idl-USVString">https://heycam.github.io/webidl/#idl-USVString</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-idl-USVString">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-idl-USVString①">7.4. Interface TextEncoder</a> <a href="#ref-for-idl-USVString②">(2)</a>
    <li><a href="#ref-for-idl-USVString③">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-idl-Uint32Array">
   <a href="https://heycam.github.io/webidl/#idl-Uint32Array">https://heycam.github.io/webidl/#idl-Uint32Array</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-idl-Uint32Array">7. API</a> <a href="#ref-for-idl-Uint32Array①">(2)</a> <a href="#ref-for-idl-Uint32Array②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-idl-Uint8Array">
   <a href="https://heycam.github.io/webidl/#idl-Uint8Array">https://heycam.github.io/webidl/#idl-Uint8Array</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-idl-Uint8Array">7. API</a>
    <li><a href="#ref-for-idl-Uint8Array①">7.4. Interface TextEncoder</a> <a href="#ref-for-idl-Uint8Array②">(2)</a> <a href="#ref-for-idl-Uint8Array③">(3)</a>
    <li><a href="#ref-for-idl-Uint8Array④">7.7. Interface TextEncoderStream</a> <a href="#ref-for-idl-Uint8Array⑤">(2)</a> <a href="#ref-for-idl-Uint8Array⑥">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-idl-boolean">
   <a href="https://heycam.github.io/webidl/#idl-boolean">https://heycam.github.io/webidl/#idl-boolean</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-idl-boolean">7.1. Interface mixin TextDecoderCommon</a> <a href="#ref-for-idl-boolean①">(2)</a>
    <li><a href="#ref-for-idl-boolean②">7.2. Interface TextDecoder</a> <a href="#ref-for-idl-boolean③">(2)</a> <a href="#ref-for-idl-boolean④">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-dfn-convert-ecmascript-to-idl-value">
   <a href="https://heycam.github.io/webidl/#dfn-convert-ecmascript-to-idl-value">https://heycam.github.io/webidl/#dfn-convert-ecmascript-to-idl-value</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-convert-ecmascript-to-idl-value">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-dfn-convert-ecmascript-to-idl-value①">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-dfn-get-buffer-source-copy">
   <a href="https://heycam.github.io/webidl/#dfn-get-buffer-source-copy">https://heycam.github.io/webidl/#dfn-get-buffer-source-copy</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-get-buffer-source-copy">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-dfn-get-buffer-source-copy①">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-dfn-get-buffer-source-reference">
   <a href="https://heycam.github.io/webidl/#dfn-get-buffer-source-reference">https://heycam.github.io/webidl/#dfn-get-buffer-source-reference</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-get-buffer-source-reference">7.4. Interface TextEncoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-dfn-throw">
   <a href="https://heycam.github.io/webidl/#dfn-throw">https://heycam.github.io/webidl/#dfn-throw</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dfn-throw">7.2. Interface TextDecoder</a> <a href="#ref-for-dfn-throw①">(2)</a> <a href="#ref-for-dfn-throw②">(3)</a> <a href="#ref-for-dfn-throw③">(4)</a>
    <li><a href="#ref-for-dfn-throw④">7.6. Interface TextDecoderStream</a> <a href="#ref-for-dfn-throw⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="term-for-idl-unsigned-long-long">
   <a href="https://heycam.github.io/webidl/#idl-unsigned-long-long">https://heycam.github.io/webidl/#idl-unsigned-long-long</a><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-idl-unsigned-long-long">7.4. Interface TextEncoder</a> <a href="#ref-for-idl-unsigned-long-long①">(2)</a>
   </ul>
  </aside>
  <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3>
  <ul class="index">
   <li>
    <a data-link-type="biblio">[INFRA]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-ascii-byte" style="color:initial">ascii byte</span>
     <li><span class="dfn-paneled" id="term-for-ascii-case-insensitive" style="color:initial">ascii case-insensitive</span>
     <li><span class="dfn-paneled" id="term-for-ascii-code-point" style="color:initial">ascii code point</span>
     <li><span class="dfn-paneled" id="term-for-ascii-digit" style="color:initial">ascii digit</span>
     <li><span class="dfn-paneled" id="term-for-ascii-lowercase" style="color:initial">ascii lowercase</span>
     <li><span class="dfn-paneled" id="term-for-ascii-whitespace" style="color:initial">ascii whitespace</span>
     <li><span class="dfn-paneled" id="term-for-iteration-break" style="color:initial">break</span>
     <li><span class="dfn-paneled" id="term-for-byte" style="color:initial">byte</span>
     <li><span class="dfn-paneled" id="term-for-code-point" style="color:initial">code point</span>
     <li><span class="dfn-paneled" id="term-for-code-unit" style="color:initial">code unit</span>
     <li><span class="dfn-paneled" id="term-for-javascript-string-convert" style="color:initial">convert</span>
     <li><span class="dfn-paneled" id="term-for-javascript-string" style="color:initial">javascript string</span>
     <li><span class="dfn-paneled" id="term-for-byte-sequence-length" style="color:initial">length</span>
     <li><span class="dfn-paneled" id="term-for-scalar-value" style="color:initial">scalar value</span>
     <li><span class="dfn-paneled" id="term-for-scalar-value-string" style="color:initial">scalar value string</span>
    </ul>
   <li>
    <a data-link-type="biblio">[STREAMS]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-create-transform-stream" style="color:initial">CreateTransformStream</span>
     <li><span class="dfn-paneled" id="term-for-rs-class" style="color:initial">ReadableStream</span>
     <li><span class="dfn-paneled" id="term-for-ts-class" style="color:initial">TransformStream</span>
     <li><span class="dfn-paneled" id="term-for-transform-stream-default-controller-enqueue" style="color:initial">TransformStreamDefaultControllerEnqueue</span>
     <li><span class="dfn-paneled" id="term-for-ws-class" style="color:initial">WritableStream</span>
     <li><span class="dfn-paneled" id="term-for-chunk" style="color:initial">chunk</span>
     <li><span class="dfn-paneled" id="term-for-rs-pipe-through" style="color:initial">pipeThrough(transform, options)</span>
     <li><span class="dfn-paneled" id="term-for-readable-stream" style="color:initial">readable stream</span>
     <li><span class="dfn-paneled" id="term-for-transform-stream" style="color:initial">transform stream</span>
     <li><span class="dfn-paneled" id="term-for-writable-stream" style="color:initial">writable stream</span>
    </ul>
   <li>
    <a data-link-type="biblio">[WEBIDL]</a> defines the following terms:
    <ul>
     <li><span class="dfn-paneled" id="term-for-AllowShared" style="color:initial">AllowShared</span>
     <li><span class="dfn-paneled" id="term-for-idl-ArrayBuffer" style="color:initial">ArrayBuffer</span>
     <li><span class="dfn-paneled" id="term-for-BufferSource" style="color:initial">BufferSource</span>
     <li><span class="dfn-paneled" id="term-for-idl-DOMString" style="color:initial">DOMString</span>
     <li><span class="dfn-paneled" id="term-for-Exposed" style="color:initial">Exposed</span>
     <li><span class="dfn-paneled" id="term-for-NewObject" style="color:initial">NewObject</span>
     <li><span class="dfn-paneled" id="term-for-exceptiondef-rangeerror" style="color:initial">RangeError</span>
     <li><span class="dfn-paneled" id="term-for-exceptiondef-typeerror" style="color:initial">TypeError</span>
     <li><span class="dfn-paneled" id="term-for-idl-USVString" style="color:initial">USVString</span>
     <li><span class="dfn-paneled" id="term-for-idl-Uint32Array" style="color:initial">Uint32Array</span>
     <li><span class="dfn-paneled" id="term-for-idl-Uint8Array" style="color:initial">Uint8Array</span>
     <li><span class="dfn-paneled" id="term-for-idl-boolean" style="color:initial">boolean</span>
     <li><span class="dfn-paneled" id="term-for-dfn-convert-ecmascript-to-idl-value" style="color:initial">converted to an idl value</span>
     <li><span class="dfn-paneled" id="term-for-dfn-get-buffer-source-copy" style="color:initial">get a copy of the buffer source</span>
     <li><span class="dfn-paneled" id="term-for-dfn-get-buffer-source-reference" style="color:initial">get a reference to the buffer source</span>
     <li><span class="dfn-paneled" id="term-for-dfn-throw" style="color:initial">throw</span>
     <li><span class="dfn-paneled" id="term-for-idl-unsigned-long-long" style="color:initial">unsigned long long</span>
    </ul>
  </ul>
  <h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2>
  <h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3>
  <dl>
   <dt id="biblio-infra">[INFRA]
   <dd>Anne van Kesteren; Domenic Denicola. <a href="https://infra.spec.whatwg.org/">Infra Standard</a>. Living Standard. URL: <a href="https://infra.spec.whatwg.org/">https://infra.spec.whatwg.org/</a>
   <dt id="biblio-streams">[STREAMS]
   <dd>Adam Rice; Domenic Denicola; 吉野剛史 (Takeshi Yoshino). <a href="https://streams.spec.whatwg.org/">Streams Standard</a>. Living Standard. URL: <a href="https://streams.spec.whatwg.org/">https://streams.spec.whatwg.org/</a>
   <dt id="biblio-unicode">[UNICODE]
   <dd><a href="https://www.unicode.org/versions/latest/">The Unicode Standard</a>. URL: <a href="https://www.unicode.org/versions/latest/">https://www.unicode.org/versions/latest/</a>
   <dt id="biblio-webidl">[WEBIDL]
   <dd>Boris Zbarsky. <a href="https://heycam.github.io/webidl/">Web IDL</a>. URL: <a href="https://heycam.github.io/webidl/">https://heycam.github.io/webidl/</a>
  </dl>
  <h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3>
  <dl>
   <dt id="biblio-html">[HTML]
   <dd>Anne van Kesteren; et al. <a href="https://html.spec.whatwg.org/multipage/">HTML Standard</a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a>
   <dt id="biblio-url">[URL]
   <dd>Anne van Kesteren. <a href="https://url.spec.whatwg.org/">URL Standard</a>. Living Standard. URL: <a href="https://url.spec.whatwg.org/">https://url.spec.whatwg.org/</a>
   <dt id="biblio-xml">[XML]
   <dd>Tim Bray; et al. <a href="https://www.w3.org/TR/xml/">Extensible Markup Language (XML) 1.0 (Fifth Edition)</a>. 26 November 2008. REC. URL: <a href="https://www.w3.org/TR/xml/">https://www.w3.org/TR/xml/</a>
  </dl>
  <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">IDL Index</span><a class="self-link" href="#idl-index"></a></h2>
<pre class="idl highlight def"><c- b>interface</c-> <c- b>mixin</c-> <a href="#textdecodercommon"><code><c- g>TextDecoderCommon</c-></code></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString⑥"><c- b>DOMString</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="DOMString" href="#dom-textdecoder-encoding" id="ref-for-dom-textdecoder-encoding③"><c- g>encoding</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean⑤"><c- b>boolean</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="boolean" href="#dom-textdecoder-fatal" id="ref-for-dom-textdecoder-fatal③"><c- g>fatal</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean①①"><c- b>boolean</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="boolean" href="#dom-textdecoder-ignorebom" id="ref-for-dom-textdecoder-ignorebom③"><c- g>ignoreBOM</c-></a>;
};

<c- b>dictionary</c-> <a href="#textdecoderoptions"><code><c- g>TextDecoderOptions</c-></code></a> {
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean②①"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean " href="#dom-textdecoderoptions-fatal"><code><c- g>fatal</c-></code></a> = <c- b>false</c->;
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean③①"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean " href="#dom-textdecoderoptions-ignorebom"><code><c- g>ignoreBOM</c-></code></a> = <c- b>false</c->;
};

<c- b>dictionary</c-> <a href="#textdecodeoptions"><code><c- g>TextDecodeOptions</c-></code></a> {
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-boolean" id="ref-for-idl-boolean④①"><c- b>boolean</c-></a> <a data-default="false" data-type="boolean " href="#dom-textdecodeoptions-stream"><code><c- g>stream</c-></code></a> = <c- b>false</c->;
};

[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed④"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <a href="#textdecoder"><code><c- g>TextDecoder</c-></code></a> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textdecoder" id="ref-for-dom-textdecoder②"><c- g>constructor</c-></a>(<c- b>optional</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString①①"><c- b>DOMString</c-></a> <a href="#dom-textdecoder-textdecoder-label-options-label"><code><c- g>label</c-></code></a> = "utf-8", <c- b>optional</c-> <a class="n" data-link-type="idl-name" href="#textdecoderoptions" id="ref-for-textdecoderoptions②"><c- n>TextDecoderOptions</c-></a> <a href="#dom-textdecoder-textdecoder-label-options-options"><code><c- g>options</c-></code></a> = {});

  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-USVString" id="ref-for-idl-USVString④"><c- b>USVString</c-></a> <a class="idl-code" data-link-type="method" href="#dom-textdecoder-decode" id="ref-for-dom-textdecoder-decode③"><c- g>decode</c-></a>(<c- b>optional</c-> [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#AllowShared" id="ref-for-AllowShared④"><c- g>AllowShared</c-></a>] <a class="n" data-link-type="idl-name" href="https://heycam.github.io/webidl/#BufferSource" id="ref-for-BufferSource③"><c- n>BufferSource</c-></a> <a href="#dom-textdecoder-decode-input-options-input"><code><c- g>input</c-></code></a>, <c- b>optional</c-> <a class="n" data-link-type="idl-name" href="#textdecodeoptions" id="ref-for-textdecodeoptions①"><c- n>TextDecodeOptions</c-></a> <a href="#dom-textdecoder-decode-input-options-options"><code><c- g>options</c-></code></a> = {});
};
<a class="n" data-link-type="idl-name" href="#textdecoder" id="ref-for-textdecoder②①"><c- n>TextDecoder</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textdecodercommon" id="ref-for-textdecodercommon②①"><c- n>TextDecoderCommon</c-></a>;

<c- b>interface</c-> <c- b>mixin</c-> <a href="#textencodercommon"><code><c- g>TextEncoderCommon</c-></code></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString②①"><c- b>DOMString</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="DOMString" href="#dom-textencoder-encoding" id="ref-for-dom-textencoder-encoding③"><c- g>encoding</c-></a>;
};

<c- b>dictionary</c-> <a href="#dictdef-textencoderencodeintoresult"><code><c- g>TextEncoderEncodeIntoResult</c-></code></a> {
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-unsigned-long-long" id="ref-for-idl-unsigned-long-long②"><c- b>unsigned</c-> <c- b>long</c-> <c- b>long</c-></a> <a data-type="unsigned long long " href="#dom-textencoderencodeintoresult-read"><code><c- g>read</c-></code></a>;
  <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-unsigned-long-long" id="ref-for-idl-unsigned-long-long①①"><c- b>unsigned</c-> <c- b>long</c-> <c- b>long</c-></a> <a data-type="unsigned long long " href="#dom-textencoderencodeintoresult-written"><code><c- g>written</c-></code></a>;
};

[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed①①"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <a href="#textencoder"><code><c- g>TextEncoder</c-></code></a> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textencoder" id="ref-for-dom-textencoder②"><c- g>constructor</c-></a>();

  [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#NewObject" id="ref-for-NewObject①"><c- g>NewObject</c-></a>] <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array①①"><c- b>Uint8Array</c-></a> <a class="idl-code" data-link-type="method" href="#dom-textencoder-encode" id="ref-for-dom-textencoder-encode②"><c- g>encode</c-></a>(<c- b>optional</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-USVString" id="ref-for-idl-USVString①①"><c- b>USVString</c-></a> <a href="#dom-textencoder-encode-input-input"><code><c- g>input</c-></code></a> = "");
  <a class="n" data-link-type="idl-name" href="#dictdef-textencoderencodeintoresult" id="ref-for-dictdef-textencoderencodeintoresult②"><c- n>TextEncoderEncodeIntoResult</c-></a> <a class="idl-code" data-link-type="method" href="#dom-textencoder-encodeinto" id="ref-for-dom-textencoder-encodeinto③"><c- g>encodeInto</c-></a>(<a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-USVString" id="ref-for-idl-USVString②①"><c- b>USVString</c-></a> <a href="#dom-textencoder-encodeinto-source-destination-source"><code><c- g>source</c-></code></a>, [<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#AllowShared" id="ref-for-AllowShared①①"><c- g>AllowShared</c-></a>] <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-Uint8Array" id="ref-for-idl-Uint8Array②①"><c- b>Uint8Array</c-></a> <a href="#dom-textencoder-encodeinto-source-destination-destination"><code><c- g>destination</c-></code></a>);
};
<a class="n" data-link-type="idl-name" href="#textencoder" id="ref-for-textencoder③①"><c- n>TextEncoder</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textencodercommon" id="ref-for-textencodercommon②①"><c- n>TextEncoderCommon</c-></a>;

<c- b>interface</c-> <c- b>mixin</c-> <a href="#generictransformstream"><code><c- g>GenericTransformStream</c-></code></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="n" data-link-type="idl-name" href="https://streams.spec.whatwg.org/#rs-class" id="ref-for-rs-class④"><c- n>ReadableStream</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="ReadableStream" href="#dom-generictransformstream-readable" id="ref-for-dom-generictransformstream-readable⑥"><c- g>readable</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a class="n" data-link-type="idl-name" href="https://streams.spec.whatwg.org/#ws-class" id="ref-for-ws-class①"><c- n>WritableStream</c-></a> <a class="idl-code" data-link-type="attribute" data-readonly data-type="WritableStream" href="#dom-generictransformstream-writable" id="ref-for-dom-generictransformstream-writable⑥"><c- g>writable</c-></a>;
};

[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed②①"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <a href="#textdecoderstream"><code><c- g>TextDecoderStream</c-></code></a> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textdecoderstream" id="ref-for-dom-textdecoderstream②"><c- g>constructor</c-></a>(<c- b>optional</c-> <a class="idl-code" data-link-type="interface" href="https://heycam.github.io/webidl/#idl-DOMString" id="ref-for-idl-DOMString③①"><c- b>DOMString</c-></a> <a href="#dom-textdecoderstream-textdecoderstream-label-options-label"><code><c- g>label</c-></code></a> = "utf-8", <c- b>optional</c-> <a class="n" data-link-type="idl-name" href="#textdecoderoptions" id="ref-for-textdecoderoptions①①"><c- n>TextDecoderOptions</c-></a> <a href="#dom-textdecoderstream-textdecoderstream-label-options-options"><code><c- g>options</c-></code></a> = {});
};
<a class="n" data-link-type="idl-name" href="#textdecoderstream" id="ref-for-textdecoderstream②①"><c- n>TextDecoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textdecodercommon" id="ref-for-textdecodercommon③①"><c- n>TextDecoderCommon</c-></a>;
<a class="n" data-link-type="idl-name" href="#textdecoderstream" id="ref-for-textdecoderstream③①"><c- n>TextDecoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#generictransformstream" id="ref-for-generictransformstream③①"><c- n>GenericTransformStream</c-></a>;

[<a class="idl-code" data-link-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed" id="ref-for-Exposed③①"><c- g>Exposed</c-></a>=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <a href="#textencoderstream"><code><c- g>TextEncoderStream</c-></code></a> {
  <a class="idl-code" data-link-type="constructor" href="#dom-textencoderstream" id="ref-for-dom-textencoderstream②"><c- g>constructor</c-></a>();
};
<a class="n" data-link-type="idl-name" href="#textencoderstream" id="ref-for-textencoderstream②①"><c- n>TextEncoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#textencodercommon" id="ref-for-textencodercommon③①"><c- n>TextEncoderCommon</c-></a>;
<a class="n" data-link-type="idl-name" href="#textencoderstream" id="ref-for-textencoderstream③①"><c- n>TextEncoderStream</c-></a> <c- b>includes</c-> <a class="n" data-link-type="idl-name" href="#generictransformstream" id="ref-for-generictransformstream④①"><c- n>GenericTransformStream</c-></a>;

</pre>
  <aside class="dfn-panel" data-for="concept-token">
   <b><a href="#concept-token">#concept-token</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-token">3. Terminology</a> <a href="#ref-for-concept-token①">(2)</a> <a href="#ref-for-concept-token②">(3)</a> <a href="#ref-for-concept-token③">(4)</a> <a href="#ref-for-concept-token④">(5)</a> <a href="#ref-for-concept-token⑤">(6)</a>
    <li><a href="#ref-for-concept-token⑥">4.1. Encoders and decoders</a> <a href="#ref-for-concept-token⑦">(2)</a> <a href="#ref-for-concept-token⑧">(3)</a> <a href="#ref-for-concept-token⑨">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-stream">
   <b><a href="#concept-stream">#concept-stream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-stream">3. Terminology</a> <a href="#ref-for-concept-stream①">(2)</a> <a href="#ref-for-concept-stream②">(3)</a> <a href="#ref-for-concept-stream③">(4)</a>
    <li><a href="#ref-for-concept-stream④">4.1. Encoders and decoders</a> <a href="#ref-for-concept-stream⑤">(2)</a> <a href="#ref-for-concept-stream⑥">(3)</a> <a href="#ref-for-concept-stream⑦">(4)</a> <a href="#ref-for-concept-stream⑧">(5)</a>
    <li><a href="#ref-for-concept-stream⑨">6. Hooks for standards</a> <a href="#ref-for-concept-stream①⓪">(2)</a> <a href="#ref-for-concept-stream①①">(3)</a> <a href="#ref-for-concept-stream①②">(4)</a>
    <li><a href="#ref-for-concept-stream①③">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-concept-stream①④">7.2. Interface TextDecoder</a> <a href="#ref-for-concept-stream①⑤">(2)</a>
    <li><a href="#ref-for-concept-stream①⑥">7.4. Interface TextEncoder</a> <a href="#ref-for-concept-stream①⑦">(2)</a> <a href="#ref-for-concept-stream①⑧">(3)</a> <a href="#ref-for-concept-stream①⑨">(4)</a>
    <li><a href="#ref-for-concept-stream②⓪">7.6. Interface TextDecoderStream</a> <a href="#ref-for-concept-stream②①">(2)</a> <a href="#ref-for-concept-stream②②">(3)</a>
    <li><a href="#ref-for-concept-stream②③">7.7. Interface TextEncoderStream</a> <a href="#ref-for-concept-stream②④">(2)</a>
    <li><a href="#ref-for-concept-stream②⑤">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="end-of-stream">
   <b><a href="#end-of-stream">#end-of-stream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-end-of-stream">3. Terminology</a>
    <li><a href="#ref-for-end-of-stream①">6. Hooks for standards</a>
    <li><a href="#ref-for-end-of-stream②">7.1. Interface mixin TextDecoderCommon</a> <a href="#ref-for-end-of-stream③">(2)</a>
    <li><a href="#ref-for-end-of-stream④">7.2. Interface TextDecoder</a> <a href="#ref-for-end-of-stream⑤">(2)</a>
    <li><a href="#ref-for-end-of-stream⑥">7.6. Interface TextDecoderStream</a> <a href="#ref-for-end-of-stream⑦">(2)</a>
    <li><a href="#ref-for-end-of-stream⑧">7.7. Interface TextEncoderStream</a>
    <li><a href="#ref-for-end-of-stream⑨">8.1.1. UTF-8 decoder</a> <a href="#ref-for-end-of-stream①⓪">(2)</a>
    <li><a href="#ref-for-end-of-stream①①">8.1.2. UTF-8 encoder</a>
    <li><a href="#ref-for-end-of-stream①②">9.1. single-byte decoder</a>
    <li><a href="#ref-for-end-of-stream①③">9.2. single-byte encoder</a>
    <li><a href="#ref-for-end-of-stream①④">10.2.1. gb18030 decoder</a> <a href="#ref-for-end-of-stream①⑤">(2)</a>
    <li><a href="#ref-for-end-of-stream①⑥">10.2.2. gb18030 encoder</a>
    <li><a href="#ref-for-end-of-stream①⑦">11.1.1. Big5 decoder</a> <a href="#ref-for-end-of-stream①⑧">(2)</a>
    <li><a href="#ref-for-end-of-stream①⑨">11.1.2. Big5 encoder</a>
    <li><a href="#ref-for-end-of-stream②⓪">12.1.1. EUC-JP decoder</a> <a href="#ref-for-end-of-stream②①">(2)</a>
    <li><a href="#ref-for-end-of-stream②②">12.1.2. EUC-JP encoder</a>
    <li><a href="#ref-for-end-of-stream②③">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-end-of-stream②④">(2)</a> <a href="#ref-for-end-of-stream②⑤">(3)</a> <a href="#ref-for-end-of-stream②⑥">(4)</a> <a href="#ref-for-end-of-stream②⑦">(5)</a>
    <li><a href="#ref-for-end-of-stream②⑧">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-end-of-stream②⑨">(2)</a>
    <li><a href="#ref-for-end-of-stream③⓪">12.3.1. Shift_JIS decoder</a> <a href="#ref-for-end-of-stream③①">(2)</a>
    <li><a href="#ref-for-end-of-stream③②">12.3.2. Shift_JIS encoder</a>
    <li><a href="#ref-for-end-of-stream③③">13.1.1. EUC-KR decoder</a> <a href="#ref-for-end-of-stream③④">(2)</a>
    <li><a href="#ref-for-end-of-stream③⑤">13.1.2. EUC-KR encoder</a>
    <li><a href="#ref-for-end-of-stream③⑥">14.1.1. replacement decoder</a>
    <li><a href="#ref-for-end-of-stream③⑦">14.2.1. shared UTF-16 decoder</a> <a href="#ref-for-end-of-stream③⑧">(2)</a>
    <li><a href="#ref-for-end-of-stream③⑨">14.5.1. x-user-defined decoder</a>
    <li><a href="#ref-for-end-of-stream④⓪">14.5.2. x-user-defined encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-stream-read">
   <b><a href="#concept-stream-read">#concept-stream-read</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-stream-read">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-concept-stream-read①">6. Hooks for standards</a> <a href="#ref-for-concept-stream-read②">(2)</a> <a href="#ref-for-concept-stream-read③">(3)</a>
    <li><a href="#ref-for-concept-stream-read④">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-concept-stream-read⑤">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-concept-stream-read⑥">7.4. Interface TextEncoder</a> <a href="#ref-for-concept-stream-read⑦">(2)</a>
    <li><a href="#ref-for-concept-stream-read⑧">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-concept-stream-read⑨">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-stream-prepend">
   <b><a href="#concept-stream-prepend">#concept-stream-prepend</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-stream-prepend">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-concept-stream-prepend①">6. Hooks for standards</a> <a href="#ref-for-concept-stream-prepend②">(2)</a> <a href="#ref-for-concept-stream-prepend③">(3)</a>
    <li><a href="#ref-for-concept-stream-prepend④">7.7. Interface TextEncoderStream</a>
    <li><a href="#ref-for-concept-stream-prepend⑤">8.1.1. UTF-8 decoder</a>
    <li><a href="#ref-for-concept-stream-prepend⑥">10.2.1. gb18030 decoder</a> <a href="#ref-for-concept-stream-prepend⑦">(2)</a> <a href="#ref-for-concept-stream-prepend⑧">(3)</a>
    <li><a href="#ref-for-concept-stream-prepend⑨">11.1.1. Big5 decoder</a>
    <li><a href="#ref-for-concept-stream-prepend①⓪">12.1.1. EUC-JP decoder</a>
    <li><a href="#ref-for-concept-stream-prepend①①">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-concept-stream-prepend①②">(2)</a> <a href="#ref-for-concept-stream-prepend①③">(3)</a>
    <li><a href="#ref-for-concept-stream-prepend①④">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-concept-stream-prepend①⑤">(2)</a> <a href="#ref-for-concept-stream-prepend①⑥">(3)</a> <a href="#ref-for-concept-stream-prepend①⑦">(4)</a>
    <li><a href="#ref-for-concept-stream-prepend①⑧">12.3.1. Shift_JIS decoder</a>
    <li><a href="#ref-for-concept-stream-prepend①⑨">13.1.1. EUC-KR decoder</a>
    <li><a href="#ref-for-concept-stream-prepend②⓪">14.2.1. shared UTF-16 decoder</a>
    <li><a href="#ref-for-concept-stream-prepend②①">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-stream-push">
   <b><a href="#concept-stream-push">#concept-stream-push</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-stream-push">4.1. Encoders and decoders</a> <a href="#ref-for-concept-stream-push①">(2)</a>
    <li><a href="#ref-for-concept-stream-push②">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-concept-stream-push③">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="encoding">
   <b><a href="#encoding">#encoding</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-encoding">4. Encodings</a> <a href="#ref-for-encoding①">(2)</a> <a href="#ref-for-encoding②">(3)</a> <a href="#ref-for-encoding③">(4)</a>
    <li><a href="#ref-for-encoding④">4.1. Encoders and decoders</a> <a href="#ref-for-encoding⑤">(2)</a> <a href="#ref-for-encoding⑥">(3)</a> <a href="#ref-for-encoding⑦">(4)</a> <a href="#ref-for-encoding⑧">(5)</a>
    <li><a href="#ref-for-encoding⑨">4.2. Names and labels</a> <a href="#ref-for-encoding①⓪">(2)</a> <a href="#ref-for-encoding①①">(3)</a> <a href="#ref-for-encoding①②">(4)</a> <a href="#ref-for-encoding①③">(5)</a> <a href="#ref-for-encoding①④">(6)</a> <a href="#ref-for-encoding①⑤">(7)</a> <a href="#ref-for-encoding①⑥">(8)</a>
    <li><a href="#ref-for-encoding①⑦">4.3. Output encodings</a>
    <li><a href="#ref-for-encoding①⑧">5. Indexes</a> <a href="#ref-for-encoding①⑨">(2)</a>
    <li><a href="#ref-for-encoding②⓪">6. Hooks for standards</a> <a href="#ref-for-encoding②①">(2)</a>
    <li><a href="#ref-for-encoding②②">9. Legacy single-byte encodings</a> <a href="#ref-for-encoding②③">(2)</a>
    <li><a href="#ref-for-encoding②④">14.1. replacement</a> <a href="#ref-for-encoding②⑤">(2)</a>
    <li><a href="#ref-for-encoding②⑥">Implementation considerations</a> <a href="#ref-for-encoding②⑦">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="name">
   <b><a href="#name">#name</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-name">4.2. Names and labels</a> <a href="#ref-for-name①">(2)</a> <a href="#ref-for-name②">(3)</a>
    <li><a href="#ref-for-name③">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-name④">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-name⑤">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-name⑥">9. Legacy single-byte encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="label">
   <b><a href="#label">#label</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-label">4.2. Names and labels</a> <a href="#ref-for-label①">(2)</a> <a href="#ref-for-label②">(3)</a> <a href="#ref-for-label③">(4)</a> <a href="#ref-for-label④">(5)</a> <a href="#ref-for-label⑤">(6)</a> <a href="#ref-for-label⑥">(7)</a> <a href="#ref-for-label⑦">(8)</a> <a href="#ref-for-label⑧">(9)</a>
    <li><a href="#ref-for-label⑨">6. Hooks for standards</a>
    <li><a href="#ref-for-label①⓪">7.2. Interface TextDecoder</a> <a href="#ref-for-label①①">(2)</a>
    <li><a href="#ref-for-label①②">7.6. Interface TextDecoderStream</a> <a href="#ref-for-label①③">(2)</a>
    <li><a href="#ref-for-label①④">8.1.1. UTF-8 decoder</a>
    <li><a href="#ref-for-label①⑤">14.2.1. shared UTF-16 decoder</a>
    <li><a href="#ref-for-label①⑥">14.4. UTF-16LE</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="decoder">
   <b><a href="#decoder">#decoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-decoder">4.1. Encoders and decoders</a> <a href="#ref-for-decoder①">(2)</a> <a href="#ref-for-decoder②">(3)</a> <a href="#ref-for-decoder③">(4)</a> <a href="#ref-for-decoder④">(5)</a> <a href="#ref-for-decoder⑤">(6)</a>
    <li><a href="#ref-for-decoder⑥">5. Indexes</a>
    <li><a href="#ref-for-decoder⑦">6. Hooks for standards</a> <a href="#ref-for-decoder⑧">(2)</a> <a href="#ref-for-decoder⑨">(3)</a> <a href="#ref-for-decoder①⓪">(4)</a>
    <li><a href="#ref-for-decoder①①">7.2. Interface TextDecoder</a> <a href="#ref-for-decoder①②">(2)</a> <a href="#ref-for-decoder①③">(3)</a>
    <li><a href="#ref-for-decoder①④">7.6. Interface TextDecoderStream</a> <a href="#ref-for-decoder①⑤">(2)</a> <a href="#ref-for-decoder①⑥">(3)</a> <a href="#ref-for-decoder①⑦">(4)</a>
    <li><a href="#ref-for-decoder①⑧">8.1.1. UTF-8 decoder</a> <a href="#ref-for-decoder①⑨">(2)</a>
    <li><a href="#ref-for-decoder②⓪">9. Legacy single-byte encodings</a>
    <li><a href="#ref-for-decoder②①">9.1. single-byte decoder</a>
    <li><a href="#ref-for-decoder②②">10.1.1. GBK decoder</a> <a href="#ref-for-decoder②③">(2)</a>
    <li><a href="#ref-for-decoder②④">10.2.1. gb18030 decoder</a> <a href="#ref-for-decoder②⑤">(2)</a>
    <li><a href="#ref-for-decoder②⑥">11.1.1. Big5 decoder</a> <a href="#ref-for-decoder②⑦">(2)</a>
    <li><a href="#ref-for-decoder②⑧">12.1.1. EUC-JP decoder</a> <a href="#ref-for-decoder②⑨">(2)</a>
    <li><a href="#ref-for-decoder③⓪">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-decoder③①">(2)</a>
    <li><a href="#ref-for-decoder③②">12.2.2. ISO-2022-JP encoder</a>
    <li><a href="#ref-for-decoder③③">12.3.1. Shift_JIS decoder</a> <a href="#ref-for-decoder③④">(2)</a>
    <li><a href="#ref-for-decoder③⑤">13.1.1. EUC-KR decoder</a> <a href="#ref-for-decoder③⑥">(2)</a>
    <li><a href="#ref-for-decoder③⑦">14.1.1. replacement decoder</a> <a href="#ref-for-decoder③⑧">(2)</a>
    <li><a href="#ref-for-decoder③⑨">14.3.1. UTF-16BE decoder</a>
    <li><a href="#ref-for-decoder④⓪">14.4.1. UTF-16LE decoder</a>
    <li><a href="#ref-for-decoder④①">14.5.1. x-user-defined decoder</a>
    <li><a href="#ref-for-decoder④②">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="encoder">
   <b><a href="#encoder">#encoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-encoder">4.1. Encoders and decoders</a> <a href="#ref-for-encoder①">(2)</a> <a href="#ref-for-encoder②">(3)</a> <a href="#ref-for-encoder③">(4)</a> <a href="#ref-for-encoder④">(5)</a> <a href="#ref-for-encoder⑤">(6)</a>
    <li><a href="#ref-for-encoder⑥">5. Indexes</a>
    <li><a href="#ref-for-encoder⑦">6. Hooks for standards</a>
    <li><a href="#ref-for-encoder⑧">7.4. Interface TextEncoder</a> <a href="#ref-for-encoder⑨">(2)</a>
    <li><a href="#ref-for-encoder①⓪">7.7. Interface TextEncoderStream</a> <a href="#ref-for-encoder①①">(2)</a> <a href="#ref-for-encoder①②">(3)</a>
    <li><a href="#ref-for-encoder①③">8.1.2. UTF-8 encoder</a>
    <li><a href="#ref-for-encoder①④">9. Legacy single-byte encodings</a>
    <li><a href="#ref-for-encoder①⑤">9.2. single-byte encoder</a>
    <li><a href="#ref-for-encoder①⑥">10.1.2. GBK encoder</a> <a href="#ref-for-encoder①⑦">(2)</a> <a href="#ref-for-encoder①⑧">(3)</a>
    <li><a href="#ref-for-encoder①⑨">10.2.2. gb18030 encoder</a> <a href="#ref-for-encoder②⓪">(2)</a>
    <li><a href="#ref-for-encoder②①">11.1.2. Big5 encoder</a>
    <li><a href="#ref-for-encoder②②">12.1.2. EUC-JP encoder</a>
    <li><a href="#ref-for-encoder②③">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-encoder②④">(2)</a> <a href="#ref-for-encoder②⑤">(3)</a>
    <li><a href="#ref-for-encoder②⑥">12.3.2. Shift_JIS encoder</a>
    <li><a href="#ref-for-encoder②⑦">13.1.2. EUC-KR encoder</a>
    <li><a href="#ref-for-encoder②⑧">14.5.2. x-user-defined encoder</a>
    <li><a href="#ref-for-encoder②⑨">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="handler">
   <b><a href="#handler">#handler</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-handler">4.1. Encoders and decoders</a> <a href="#ref-for-handler①">(2)</a>
    <li><a href="#ref-for-handler②">7.4. Interface TextEncoder</a> <a href="#ref-for-handler③">(2)</a>
    <li><a href="#ref-for-handler④">8.1.1. UTF-8 decoder</a>
    <li><a href="#ref-for-handler⑤">8.1.2. UTF-8 encoder</a>
    <li><a href="#ref-for-handler⑥">9.1. single-byte decoder</a>
    <li><a href="#ref-for-handler⑦">9.2. single-byte encoder</a>
    <li><a href="#ref-for-handler⑧">10.2.1. gb18030 decoder</a>
    <li><a href="#ref-for-handler⑨">10.2.2. gb18030 encoder</a>
    <li><a href="#ref-for-handler①⓪">11.1.1. Big5 decoder</a>
    <li><a href="#ref-for-handler①①">11.1.2. Big5 encoder</a>
    <li><a href="#ref-for-handler①②">12.1.1. EUC-JP decoder</a>
    <li><a href="#ref-for-handler①③">12.1.2. EUC-JP encoder</a>
    <li><a href="#ref-for-handler①④">12.2.1. ISO-2022-JP decoder</a>
    <li><a href="#ref-for-handler①⑤">12.2.2. ISO-2022-JP encoder</a>
    <li><a href="#ref-for-handler①⑥">12.3.1. Shift_JIS decoder</a>
    <li><a href="#ref-for-handler①⑦">12.3.2. Shift_JIS encoder</a>
    <li><a href="#ref-for-handler①⑧">13.1.1. EUC-KR decoder</a>
    <li><a href="#ref-for-handler①⑨">13.1.2. EUC-KR encoder</a>
    <li><a href="#ref-for-handler②⓪">14.1.1. replacement decoder</a>
    <li><a href="#ref-for-handler②①">14.2.1. shared UTF-16 decoder</a>
    <li><a href="#ref-for-handler②②">14.5.1. x-user-defined decoder</a>
    <li><a href="#ref-for-handler②③">14.5.2. x-user-defined encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="finished">
   <b><a href="#finished">#finished</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-finished">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-finished①">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-finished②">7.4. Interface TextEncoder</a> <a href="#ref-for-finished③">(2)</a>
    <li><a href="#ref-for-finished④">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-finished⑤">8.1.1. UTF-8 decoder</a>
    <li><a href="#ref-for-finished⑥">8.1.2. UTF-8 encoder</a>
    <li><a href="#ref-for-finished⑦">9.1. single-byte decoder</a>
    <li><a href="#ref-for-finished⑧">9.2. single-byte encoder</a>
    <li><a href="#ref-for-finished⑨">10.2.1. gb18030 decoder</a>
    <li><a href="#ref-for-finished①⓪">10.2.2. gb18030 encoder</a>
    <li><a href="#ref-for-finished①①">11.1.1. Big5 decoder</a>
    <li><a href="#ref-for-finished①②">11.1.2. Big5 encoder</a>
    <li><a href="#ref-for-finished①③">12.1.1. EUC-JP decoder</a>
    <li><a href="#ref-for-finished①④">12.1.2. EUC-JP encoder</a>
    <li><a href="#ref-for-finished①⑤">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-finished①⑥">(2)</a> <a href="#ref-for-finished①⑦">(3)</a> <a href="#ref-for-finished①⑧">(4)</a>
    <li><a href="#ref-for-finished①⑨">12.2.2. ISO-2022-JP encoder</a>
    <li><a href="#ref-for-finished②⓪">12.3.1. Shift_JIS decoder</a>
    <li><a href="#ref-for-finished②①">12.3.2. Shift_JIS encoder</a>
    <li><a href="#ref-for-finished②②">13.1.1. EUC-KR decoder</a>
    <li><a href="#ref-for-finished②③">13.1.2. EUC-KR encoder</a>
    <li><a href="#ref-for-finished②④">14.1.1. replacement decoder</a> <a href="#ref-for-finished②⑤">(2)</a>
    <li><a href="#ref-for-finished②⑥">14.2.1. shared UTF-16 decoder</a>
    <li><a href="#ref-for-finished②⑦">14.5.1. x-user-defined decoder</a>
    <li><a href="#ref-for-finished②⑧">14.5.2. x-user-defined encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="error">
   <b><a href="#error">#error</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-error">4.1. Encoders and decoders</a> <a href="#ref-for-error①">(2)</a>
    <li><a href="#ref-for-error②">6. Hooks for standards</a> <a href="#ref-for-error③">(2)</a>
    <li><a href="#ref-for-error④">7.2. Interface TextDecoder</a> <a href="#ref-for-error⑤">(2)</a>
    <li><a href="#ref-for-error⑥">7.4. Interface TextEncoder</a> <a href="#ref-for-error⑦">(2)</a>
    <li><a href="#ref-for-error⑧">7.6. Interface TextDecoderStream</a> <a href="#ref-for-error⑨">(2)</a>
    <li><a href="#ref-for-error①⓪">8.1.1. UTF-8 decoder</a> <a href="#ref-for-error①①">(2)</a> <a href="#ref-for-error①②">(3)</a>
    <li><a href="#ref-for-error①③">9.1. single-byte decoder</a>
    <li><a href="#ref-for-error①④">9.2. single-byte encoder</a>
    <li><a href="#ref-for-error①⑤">10.2.1. gb18030 decoder</a> <a href="#ref-for-error①⑥">(2)</a> <a href="#ref-for-error①⑦">(3)</a> <a href="#ref-for-error①⑧">(4)</a> <a href="#ref-for-error①⑨">(5)</a> <a href="#ref-for-error②⓪">(6)</a>
    <li><a href="#ref-for-error②①">10.2.2. gb18030 encoder</a> <a href="#ref-for-error②②">(2)</a>
    <li><a href="#ref-for-error②③">11.1.1. Big5 decoder</a> <a href="#ref-for-error②④">(2)</a> <a href="#ref-for-error②⑤">(3)</a>
    <li><a href="#ref-for-error②⑥">11.1.2. Big5 encoder</a>
    <li><a href="#ref-for-error②⑦">12.1.1. EUC-JP decoder</a> <a href="#ref-for-error②⑧">(2)</a> <a href="#ref-for-error②⑨">(3)</a>
    <li><a href="#ref-for-error③⓪">12.1.2. EUC-JP encoder</a>
    <li><a href="#ref-for-error③①">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-error③②">(2)</a> <a href="#ref-for-error③③">(3)</a> <a href="#ref-for-error③④">(4)</a> <a href="#ref-for-error③⑤">(5)</a> <a href="#ref-for-error③⑥">(6)</a> <a href="#ref-for-error③⑦">(7)</a> <a href="#ref-for-error③⑧">(8)</a> <a href="#ref-for-error③⑨">(9)</a> <a href="#ref-for-error④⓪">(10)</a> <a href="#ref-for-error④①">(11)</a>
    <li><a href="#ref-for-error④②">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-error④③">(2)</a> <a href="#ref-for-error④④">(3)</a>
    <li><a href="#ref-for-error④⑤">12.3.1. Shift_JIS decoder</a> <a href="#ref-for-error④⑥">(2)</a> <a href="#ref-for-error④⑦">(3)</a>
    <li><a href="#ref-for-error④⑧">12.3.2. Shift_JIS encoder</a>
    <li><a href="#ref-for-error④⑨">13.1.1. EUC-KR decoder</a> <a href="#ref-for-error⑤⓪">(2)</a> <a href="#ref-for-error⑤①">(3)</a>
    <li><a href="#ref-for-error⑤②">13.1.2. EUC-KR encoder</a>
    <li><a href="#ref-for-error⑤③">14.1.1. replacement decoder</a>
    <li><a href="#ref-for-error⑤④">14.2.1. shared UTF-16 decoder</a> <a href="#ref-for-error⑤⑤">(2)</a> <a href="#ref-for-error⑤⑥">(3)</a>
    <li><a href="#ref-for-error⑤⑦">14.5.2. x-user-defined encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="continue">
   <b><a href="#continue">#continue</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-continue">4.1. Encoders and decoders</a> <a href="#ref-for-continue①">(2)</a> <a href="#ref-for-continue②">(3)</a>
    <li><a href="#ref-for-continue③">7.7. Interface TextEncoderStream</a> <a href="#ref-for-continue④">(2)</a>
    <li><a href="#ref-for-continue⑤">8.1.1. UTF-8 decoder</a> <a href="#ref-for-continue⑥">(2)</a>
    <li><a href="#ref-for-continue⑦">10.2.1. gb18030 decoder</a> <a href="#ref-for-continue⑧">(2)</a> <a href="#ref-for-continue⑨">(3)</a>
    <li><a href="#ref-for-continue①⓪">11.1.1. Big5 decoder</a>
    <li><a href="#ref-for-continue①①">12.1.1. EUC-JP decoder</a> <a href="#ref-for-continue①②">(2)</a>
    <li><a href="#ref-for-continue①③">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-continue①④">(2)</a> <a href="#ref-for-continue①⑤">(3)</a> <a href="#ref-for-continue①⑥">(4)</a> <a href="#ref-for-continue①⑦">(5)</a> <a href="#ref-for-continue①⑧">(6)</a> <a href="#ref-for-continue①⑨">(7)</a>
    <li><a href="#ref-for-continue②⓪">12.3.1. Shift_JIS decoder</a>
    <li><a href="#ref-for-continue②①">13.1.1. EUC-KR decoder</a>
    <li><a href="#ref-for-continue②②">14.2.1. shared UTF-16 decoder</a> <a href="#ref-for-continue②③">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="error-mode">
   <b><a href="#error-mode">#error-mode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-error-mode">4.1. Encoders and decoders</a> <a href="#ref-for-error-mode①">(2)</a> <a href="#ref-for-error-mode②">(3)</a> <a href="#ref-for-error-mode③">(4)</a> <a href="#ref-for-error-mode④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-encoding-run">
   <b><a href="#concept-encoding-run">#concept-encoding-run</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-encoding-run">6. Hooks for standards</a> <a href="#ref-for-concept-encoding-run①">(2)</a> <a href="#ref-for-concept-encoding-run②">(3)</a> <a href="#ref-for-concept-encoding-run③">(4)</a> <a href="#ref-for-concept-encoding-run④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-encoding-process">
   <b><a href="#concept-encoding-process">#concept-encoding-process</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-encoding-process">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-concept-encoding-process①">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-concept-encoding-process②">7.4. Interface TextEncoder</a>
    <li><a href="#ref-for-concept-encoding-process③">7.6. Interface TextDecoderStream</a> <a href="#ref-for-concept-encoding-process④">(2)</a>
    <li><a href="#ref-for-concept-encoding-process⑤">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-encoding-get">
   <b><a href="#concept-encoding-get">#concept-encoding-get</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-encoding-get">6. Hooks for standards</a>
    <li><a href="#ref-for-concept-encoding-get①">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-concept-encoding-get②">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="get-an-output-encoding">
   <b><a href="#get-an-output-encoding">#get-an-output-encoding</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-get-an-output-encoding">4.3. Output encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index">
   <b><a href="#index">#index</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index">5. Indexes</a> <a href="#ref-for-index①">(2)</a> <a href="#ref-for-index②">(3)</a> <a href="#ref-for-index③">(4)</a> <a href="#ref-for-index④">(5)</a> <a href="#ref-for-index⑤">(6)</a> <a href="#ref-for-index⑥">(7)</a> <a href="#ref-for-index⑦">(8)</a> <a href="#ref-for-index⑧">(9)</a> <a href="#ref-for-index⑨">(10)</a> <a href="#ref-for-index①⓪">(11)</a>
    <li><a href="#ref-for-index①①">9. Legacy single-byte encodings</a>
    <li><a href="#ref-for-index①②">11.1.1. Big5 decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-code-point">
   <b><a href="#index-code-point">#index-code-point</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-code-point">9.1. single-byte decoder</a>
    <li><a href="#ref-for-index-code-point①">10.2.1. gb18030 decoder</a>
    <li><a href="#ref-for-index-code-point②">11.1.1. Big5 decoder</a>
    <li><a href="#ref-for-index-code-point③">12.1.1. EUC-JP decoder</a>
    <li><a href="#ref-for-index-code-point④">12.2.1. ISO-2022-JP decoder</a>
    <li><a href="#ref-for-index-code-point⑤">12.2.2. ISO-2022-JP encoder</a>
    <li><a href="#ref-for-index-code-point⑥">12.3.1. Shift_JIS decoder</a>
    <li><a href="#ref-for-index-code-point⑦">13.1.1. EUC-KR decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-pointer">
   <b><a href="#index-pointer">#index-pointer</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-pointer">5. Indexes</a> <a href="#ref-for-index-pointer①">(2)</a>
    <li><a href="#ref-for-index-pointer②">9.2. single-byte encoder</a>
    <li><a href="#ref-for-index-pointer③">10.2.2. gb18030 encoder</a>
    <li><a href="#ref-for-index-pointer④">12.1.2. EUC-JP encoder</a> <a href="#ref-for-index-pointer⑤">(2)</a>
    <li><a href="#ref-for-index-pointer⑥">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-index-pointer⑦">(2)</a>
    <li><a href="#ref-for-index-pointer⑧">13.1.2. EUC-KR encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-big5">
   <b><a href="#index-big5">#index-big5</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-big5">5. Indexes</a>
    <li><a href="#ref-for-index-big5①">11.1.1. Big5 decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-euc-kr">
   <b><a href="#index-euc-kr">#index-euc-kr</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-euc-kr">13.1.1. EUC-KR decoder</a>
    <li><a href="#ref-for-index-euc-kr①">13.1.2. EUC-KR encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-gb18030">
   <b><a href="#index-gb18030">#index-gb18030</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-gb18030">10.2.1. gb18030 decoder</a>
    <li><a href="#ref-for-index-gb18030①">10.2.2. gb18030 encoder</a> <a href="#ref-for-index-gb18030②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-gb18030-ranges">
   <b><a href="#index-gb18030-ranges">#index-gb18030-ranges</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-gb18030-ranges">5. Indexes</a> <a href="#ref-for-index-gb18030-ranges①">(2)</a> <a href="#ref-for-index-gb18030-ranges②">(3)</a> <a href="#ref-for-index-gb18030-ranges③">(4)</a> <a href="#ref-for-index-gb18030-ranges④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-jis0208">
   <b><a href="#index-jis0208">#index-jis0208</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-jis0208">5. Indexes</a> <a href="#ref-for-index-jis0208①">(2)</a> <a href="#ref-for-index-jis0208②">(3)</a>
    <li><a href="#ref-for-index-jis0208③">12.1.1. EUC-JP decoder</a>
    <li><a href="#ref-for-index-jis0208④">12.1.2. EUC-JP encoder</a> <a href="#ref-for-index-jis0208⑤">(2)</a>
    <li><a href="#ref-for-index-jis0208⑥">12.2.1. ISO-2022-JP decoder</a>
    <li><a href="#ref-for-index-jis0208⑦">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-index-jis0208⑧">(2)</a>
    <li><a href="#ref-for-index-jis0208⑨">12.3.1. Shift_JIS decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-jis0212">
   <b><a href="#index-jis0212">#index-jis0212</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-jis0212">12.1.1. EUC-JP decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-iso-2022-jp-katakana">
   <b><a href="#index-iso-2022-jp-katakana">#index-iso-2022-jp-katakana</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-iso-2022-jp-katakana">5. Indexes</a> <a href="#ref-for-index-iso-2022-jp-katakana①">(2)</a>
    <li><a href="#ref-for-index-iso-2022-jp-katakana②">12.2.2. ISO-2022-JP encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-gb18030-ranges-code-point">
   <b><a href="#index-gb18030-ranges-code-point">#index-gb18030-ranges-code-point</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-gb18030-ranges-code-point">5. Indexes</a>
    <li><a href="#ref-for-index-gb18030-ranges-code-point①">10.2.1. gb18030 decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-gb18030-ranges-pointer">
   <b><a href="#index-gb18030-ranges-pointer">#index-gb18030-ranges-pointer</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-gb18030-ranges-pointer">5. Indexes</a>
    <li><a href="#ref-for-index-gb18030-ranges-pointer①">10.2.2. gb18030 encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-shift_jis-pointer">
   <b><a href="#index-shift_jis-pointer">#index-shift_jis-pointer</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-shift_jis-pointer">12.3.2. Shift_JIS encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-big5-pointer">
   <b><a href="#index-big5-pointer">#index-big5-pointer</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-big5-pointer">11.1.2. Big5 encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="decode">
   <b><a href="#decode">#decode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-decode">6. Hooks for standards</a> <a href="#ref-for-decode①">(2)</a>
    <li><a href="#ref-for-decode②">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-decode③">8.1.1. UTF-8 decoder</a>
    <li><a href="#ref-for-decode④">14.2.1. shared UTF-16 decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-decode">
   <b><a href="#utf-8-decode">#utf-8-decode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-decode">4. Encodings</a>
    <li><a href="#ref-for-utf-8-decode①">6. Hooks for standards</a> <a href="#ref-for-utf-8-decode②">(2)</a>
    <li><a href="#ref-for-utf-8-decode③">8.1.1. UTF-8 decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-decode-without-bom">
   <b><a href="#utf-8-decode-without-bom">#utf-8-decode-without-bom</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-decode-without-bom">6. Hooks for standards</a> <a href="#ref-for-utf-8-decode-without-bom①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-decode-without-bom-or-fail">
   <b><a href="#utf-8-decode-without-bom-or-fail">#utf-8-decode-without-bom-or-fail</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-decode-without-bom-or-fail">6. Hooks for standards</a> <a href="#ref-for-utf-8-decode-without-bom-or-fail①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="encode">
   <b><a href="#encode">#encode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-encode">6. Hooks for standards</a> <a href="#ref-for-encode①">(2)</a> <a href="#ref-for-encode②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-encode">
   <b><a href="#utf-8-encode">#utf-8-encode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-encode">6. Hooks for standards</a> <a href="#ref-for-utf-8-encode①">(2)</a> <a href="#ref-for-utf-8-encode②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecodercommon">
   <b><a href="#textdecodercommon">#textdecodercommon</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecodercommon">7.1. Interface mixin TextDecoderCommon</a> <a href="#ref-for-textdecodercommon①">(2)</a>
    <li><a href="#ref-for-textdecodercommon②">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-textdecodercommon③">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder-encoding">
   <b><a href="#textdecoder-encoding">#textdecoder-encoding</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder-encoding">7.1. Interface mixin TextDecoderCommon</a> <a href="#ref-for-textdecoder-encoding①">(2)</a>
    <li><a href="#ref-for-textdecoder-encoding②">7.2. Interface TextDecoder</a> <a href="#ref-for-textdecoder-encoding③">(2)</a> <a href="#ref-for-textdecoder-encoding④">(3)</a> <a href="#ref-for-textdecoder-encoding⑤">(4)</a> <a href="#ref-for-textdecoder-encoding⑥">(5)</a>
    <li><a href="#ref-for-textdecoder-encoding⑦">7.6. Interface TextDecoderStream</a> <a href="#ref-for-textdecoder-encoding⑧">(2)</a> <a href="#ref-for-textdecoder-encoding⑨">(3)</a> <a href="#ref-for-textdecoder-encoding①⓪">(4)</a> <a href="#ref-for-textdecoder-encoding①①">(5)</a> <a href="#ref-for-textdecoder-encoding①②">(6)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder-ignore-bom-flag">
   <b><a href="#textdecoder-ignore-bom-flag">#textdecoder-ignore-bom-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder-ignore-bom-flag">7.1. Interface mixin TextDecoderCommon</a> <a href="#ref-for-textdecoder-ignore-bom-flag①">(2)</a>
    <li><a href="#ref-for-textdecoder-ignore-bom-flag②">7.2. Interface TextDecoder</a> <a href="#ref-for-textdecoder-ignore-bom-flag③">(2)</a>
    <li><a href="#ref-for-textdecoder-ignore-bom-flag④">7.6. Interface TextDecoderStream</a> <a href="#ref-for-textdecoder-ignore-bom-flag⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder-bom-seen-flag">
   <b><a href="#textdecoder-bom-seen-flag">#textdecoder-bom-seen-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder-bom-seen-flag">7.1. Interface mixin TextDecoderCommon</a> <a href="#ref-for-textdecoder-bom-seen-flag①">(2)</a> <a href="#ref-for-textdecoder-bom-seen-flag②">(3)</a>
    <li><a href="#ref-for-textdecoder-bom-seen-flag③">7.2. Interface TextDecoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder-error-mode">
   <b><a href="#textdecoder-error-mode">#textdecoder-error-mode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder-error-mode">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-textdecoder-error-mode①">7.2. Interface TextDecoder</a> <a href="#ref-for-textdecoder-error-mode②">(2)</a> <a href="#ref-for-textdecoder-error-mode③">(3)</a> <a href="#ref-for-textdecoder-error-mode④">(4)</a>
    <li><a href="#ref-for-textdecoder-error-mode⑤">7.6. Interface TextDecoderStream</a> <a href="#ref-for-textdecoder-error-mode⑥">(2)</a> <a href="#ref-for-textdecoder-error-mode⑦">(3)</a> <a href="#ref-for-textdecoder-error-mode⑧">(4)</a> <a href="#ref-for-textdecoder-error-mode⑨">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="concept-td-serialize">
   <b><a href="#concept-td-serialize">#concept-td-serialize</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-concept-td-serialize">7.2. Interface TextDecoder</a> <a href="#ref-for-concept-td-serialize①">(2)</a>
    <li><a href="#ref-for-concept-td-serialize②">7.6. Interface TextDecoderStream</a> <a href="#ref-for-concept-td-serialize③">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textdecoder-encoding">
   <b><a href="#dom-textdecoder-encoding">#dom-textdecoder-encoding</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textdecoder-encoding">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-dom-textdecoder-encoding①">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-dom-textdecoder-encoding②">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textdecoder-fatal">
   <b><a href="#dom-textdecoder-fatal">#dom-textdecoder-fatal</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textdecoder-fatal">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-dom-textdecoder-fatal①">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-dom-textdecoder-fatal②">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textdecoder-ignorebom">
   <b><a href="#dom-textdecoder-ignorebom">#dom-textdecoder-ignorebom</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textdecoder-ignorebom">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-dom-textdecoder-ignorebom①">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-dom-textdecoder-ignorebom②">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoderoptions">
   <b><a href="#textdecoderoptions">#textdecoderoptions</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoderoptions">7.2. Interface TextDecoder</a>
    <li><a href="#ref-for-textdecoderoptions①">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecodeoptions">
   <b><a href="#textdecodeoptions">#textdecodeoptions</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecodeoptions">7.2. Interface TextDecoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder">
   <b><a href="#textdecoder">#textdecoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-textdecoder①">7.2. Interface TextDecoder</a> <a href="#ref-for-textdecoder②">(2)</a> <a href="#ref-for-textdecoder③">(3)</a> <a href="#ref-for-textdecoder④">(4)</a> <a href="#ref-for-textdecoder⑤">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder-decoder">
   <b><a href="#textdecoder-decoder">#textdecoder-decoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder-decoder">7.2. Interface TextDecoder</a> <a href="#ref-for-textdecoder-decoder①">(2)</a> <a href="#ref-for-textdecoder-decoder②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder-stream">
   <b><a href="#textdecoder-stream">#textdecoder-stream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder-stream">7.2. Interface TextDecoder</a> <a href="#ref-for-textdecoder-stream①">(2)</a> <a href="#ref-for-textdecoder-stream②">(3)</a> <a href="#ref-for-textdecoder-stream③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoder-do-not-flush-flag">
   <b><a href="#textdecoder-do-not-flush-flag">#textdecoder-do-not-flush-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoder-do-not-flush-flag">7.2. Interface TextDecoder</a> <a href="#ref-for-textdecoder-do-not-flush-flag①">(2)</a> <a href="#ref-for-textdecoder-do-not-flush-flag②">(3)</a> <a href="#ref-for-textdecoder-do-not-flush-flag③">(4)</a> <a href="#ref-for-textdecoder-do-not-flush-flag④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textdecoder">
   <b><a href="#dom-textdecoder">#dom-textdecoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textdecoder">7.2. Interface TextDecoder</a> <a href="#ref-for-dom-textdecoder①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textdecoder-decode">
   <b><a href="#dom-textdecoder-decode">#dom-textdecoder-decode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textdecoder-decode">7.2. Interface TextDecoder</a> <a href="#ref-for-dom-textdecoder-decode①">(2)</a> <a href="#ref-for-dom-textdecoder-decode②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textencodercommon">
   <b><a href="#textencodercommon">#textencodercommon</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textencodercommon">7.3. Interface mixin TextEncoderCommon</a> <a href="#ref-for-textencodercommon①">(2)</a>
    <li><a href="#ref-for-textencodercommon②">7.4. Interface TextEncoder</a>
    <li><a href="#ref-for-textencodercommon③">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textencoder-encoding">
   <b><a href="#dom-textencoder-encoding">#dom-textencoder-encoding</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textencoder-encoding">7.3. Interface mixin TextEncoderCommon</a>
    <li><a href="#ref-for-dom-textencoder-encoding①">7.4. Interface TextEncoder</a>
    <li><a href="#ref-for-dom-textencoder-encoding②">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dictdef-textencoderencodeintoresult">
   <b><a href="#dictdef-textencoderencodeintoresult">#dictdef-textencoderencodeintoresult</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dictdef-textencoderencodeintoresult">7.4. Interface TextEncoder</a> <a href="#ref-for-dictdef-textencoderencodeintoresult①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textencoderencodeintoresult-read">
   <b><a href="#dom-textencoderencodeintoresult-read">#dom-textencoderencodeintoresult-read</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textencoderencodeintoresult-read">7.4. Interface TextEncoder</a> <a href="#ref-for-dom-textencoderencodeintoresult-read①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textencoderencodeintoresult-written">
   <b><a href="#dom-textencoderencodeintoresult-written">#dom-textencoderencodeintoresult-written</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textencoderencodeintoresult-written">7.4. Interface TextEncoder</a> <a href="#ref-for-dom-textencoderencodeintoresult-written①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textencoder">
   <b><a href="#textencoder">#textencoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textencoder">7. API</a>
    <li><a href="#ref-for-textencoder①">7.3. Interface mixin TextEncoderCommon</a>
    <li><a href="#ref-for-textencoder②">7.4. Interface TextEncoder</a> <a href="#ref-for-textencoder③">(2)</a> <a href="#ref-for-textencoder④">(3)</a> <a href="#ref-for-textencoder⑤">(4)</a> <a href="#ref-for-textencoder⑥">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textencoder">
   <b><a href="#dom-textencoder">#dom-textencoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textencoder">7.4. Interface TextEncoder</a> <a href="#ref-for-dom-textencoder①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textencoder-encode">
   <b><a href="#dom-textencoder-encode">#dom-textencoder-encode</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textencoder-encode">7.4. Interface TextEncoder</a> <a href="#ref-for-dom-textencoder-encode①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textencoder-encodeinto">
   <b><a href="#dom-textencoder-encodeinto">#dom-textencoder-encodeinto</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textencoder-encodeinto">7.4. Interface TextEncoder</a> <a href="#ref-for-dom-textencoder-encodeinto①">(2)</a> <a href="#ref-for-dom-textencoder-encodeinto②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="generictransformstream">
   <b><a href="#generictransformstream">#generictransformstream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-generictransformstream">7.5. Interface mixin GenericTransformStream</a> <a href="#ref-for-generictransformstream①">(2)</a> <a href="#ref-for-generictransformstream②">(3)</a>
    <li><a href="#ref-for-generictransformstream③">7.6. Interface TextDecoderStream</a>
    <li><a href="#ref-for-generictransformstream④">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="generictransformstream-transform">
   <b><a href="#generictransformstream-transform">#generictransformstream-transform</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-generictransformstream-transform">7.5. Interface mixin GenericTransformStream</a> <a href="#ref-for-generictransformstream-transform①">(2)</a>
    <li><a href="#ref-for-generictransformstream-transform②">7.6. Interface TextDecoderStream</a> <a href="#ref-for-generictransformstream-transform③">(2)</a> <a href="#ref-for-generictransformstream-transform④">(3)</a>
    <li><a href="#ref-for-generictransformstream-transform⑤">7.7. Interface TextEncoderStream</a> <a href="#ref-for-generictransformstream-transform⑥">(2)</a> <a href="#ref-for-generictransformstream-transform⑦">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-generictransformstream-readable">
   <b><a href="#dom-generictransformstream-readable">#dom-generictransformstream-readable</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-generictransformstream-readable">7.5. Interface mixin GenericTransformStream</a>
    <li><a href="#ref-for-dom-generictransformstream-readable①">7.6. Interface TextDecoderStream</a> <a href="#ref-for-dom-generictransformstream-readable②">(2)</a> <a href="#ref-for-dom-generictransformstream-readable③">(3)</a>
    <li><a href="#ref-for-dom-generictransformstream-readable④">7.7. Interface TextEncoderStream</a> <a href="#ref-for-dom-generictransformstream-readable⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-generictransformstream-writable">
   <b><a href="#dom-generictransformstream-writable">#dom-generictransformstream-writable</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-generictransformstream-writable">7.5. Interface mixin GenericTransformStream</a>
    <li><a href="#ref-for-dom-generictransformstream-writable①">7.6. Interface TextDecoderStream</a> <a href="#ref-for-dom-generictransformstream-writable②">(2)</a> <a href="#ref-for-dom-generictransformstream-writable③">(3)</a>
    <li><a href="#ref-for-dom-generictransformstream-writable④">7.7. Interface TextEncoderStream</a> <a href="#ref-for-dom-generictransformstream-writable⑤">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoderstream">
   <b><a href="#textdecoderstream">#textdecoderstream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoderstream">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-textdecoderstream①">7.6. Interface TextDecoderStream</a> <a href="#ref-for-textdecoderstream②">(2)</a> <a href="#ref-for-textdecoderstream③">(3)</a> <a href="#ref-for-textdecoderstream④">(4)</a> <a href="#ref-for-textdecoderstream⑤">(5)</a> <a href="#ref-for-textdecoderstream⑥">(6)</a> <a href="#ref-for-textdecoderstream⑦">(7)</a> <a href="#ref-for-textdecoderstream⑧">(8)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoderstream-decoder">
   <b><a href="#textdecoderstream-decoder">#textdecoderstream-decoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoderstream-decoder">7.6. Interface TextDecoderStream</a> <a href="#ref-for-textdecoderstream-decoder①">(2)</a> <a href="#ref-for-textdecoderstream-decoder②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textdecoderstream-stream">
   <b><a href="#textdecoderstream-stream">#textdecoderstream-stream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textdecoderstream-stream">7.6. Interface TextDecoderStream</a> <a href="#ref-for-textdecoderstream-stream①">(2)</a> <a href="#ref-for-textdecoderstream-stream②">(3)</a> <a href="#ref-for-textdecoderstream-stream③">(4)</a> <a href="#ref-for-textdecoderstream-stream④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textdecoderstream">
   <b><a href="#dom-textdecoderstream">#dom-textdecoderstream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textdecoderstream">7.6. Interface TextDecoderStream</a> <a href="#ref-for-dom-textdecoderstream①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="decode-and-enqueue-a-chunk">
   <b><a href="#decode-and-enqueue-a-chunk">#decode-and-enqueue-a-chunk</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-decode-and-enqueue-a-chunk">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="flush-and-enqueue">
   <b><a href="#flush-and-enqueue">#flush-and-enqueue</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-flush-and-enqueue">7.6. Interface TextDecoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textencoderstream">
   <b><a href="#textencoderstream">#textencoderstream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textencoderstream">7.3. Interface mixin TextEncoderCommon</a>
    <li><a href="#ref-for-textencoderstream①">7.7. Interface TextEncoderStream</a> <a href="#ref-for-textencoderstream②">(2)</a> <a href="#ref-for-textencoderstream③">(3)</a> <a href="#ref-for-textencoderstream④">(4)</a> <a href="#ref-for-textencoderstream⑤">(5)</a> <a href="#ref-for-textencoderstream⑥">(6)</a> <a href="#ref-for-textencoderstream⑦">(7)</a> <a href="#ref-for-textencoderstream⑧">(8)</a> <a href="#ref-for-textencoderstream⑨">(9)</a> <a href="#ref-for-textencoderstream①⓪">(10)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textencoderstream-encoder">
   <b><a href="#textencoderstream-encoder">#textencoderstream-encoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textencoderstream-encoder">7.7. Interface TextEncoderStream</a> <a href="#ref-for-textencoderstream-encoder①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="textencoderstream-pending-high-surrogate">
   <b><a href="#textencoderstream-pending-high-surrogate">#textencoderstream-pending-high-surrogate</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-textencoderstream-pending-high-surrogate">7.7. Interface TextEncoderStream</a> <a href="#ref-for-textencoderstream-pending-high-surrogate①">(2)</a> <a href="#ref-for-textencoderstream-pending-high-surrogate②">(3)</a> <a href="#ref-for-textencoderstream-pending-high-surrogate③">(4)</a> <a href="#ref-for-textencoderstream-pending-high-surrogate④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="dom-textencoderstream">
   <b><a href="#dom-textencoderstream">#dom-textencoderstream</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-dom-textencoderstream">7.7. Interface TextEncoderStream</a> <a href="#ref-for-dom-textencoderstream①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="encode-and-enqueue-a-chunk">
   <b><a href="#encode-and-enqueue-a-chunk">#encode-and-enqueue-a-chunk</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-encode-and-enqueue-a-chunk">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="convert-code-unit-to-scalar-value">
   <b><a href="#convert-code-unit-to-scalar-value">#convert-code-unit-to-scalar-value</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-convert-code-unit-to-scalar-value">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="encode-and-flush">
   <b><a href="#encode-and-flush">#encode-and-flush</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-encode-and-flush">7.7. Interface TextEncoderStream</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8">
   <b><a href="#utf-8">#utf-8</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8">4. Encodings</a> <a href="#ref-for-utf-8①">(2)</a>
    <li><a href="#ref-for-utf-8②">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-utf-8③">4.2. Names and labels</a> <a href="#ref-for-utf-8④">(2)</a> <a href="#ref-for-utf-8⑤">(3)</a>
    <li><a href="#ref-for-utf-8⑥">4.3. Output encodings</a>
    <li><a href="#ref-for-utf-8⑦">6. Hooks for standards</a> <a href="#ref-for-utf-8⑧">(2)</a> <a href="#ref-for-utf-8⑨">(3)</a> <a href="#ref-for-utf-8①⓪">(4)</a> <a href="#ref-for-utf-8①①">(5)</a> <a href="#ref-for-utf-8①②">(6)</a>
    <li><a href="#ref-for-utf-8①③">7. API</a> <a href="#ref-for-utf-8①④">(2)</a>
    <li><a href="#ref-for-utf-8①⑤">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-utf-8①⑥">7.4. Interface TextEncoder</a> <a href="#ref-for-utf-8①⑦">(2)</a>
    <li><a href="#ref-for-utf-8①⑧">7.7. Interface TextEncoderStream</a> <a href="#ref-for-utf-8①⑨">(2)</a> <a href="#ref-for-utf-8②⓪">(3)</a> <a href="#ref-for-utf-8②①">(4)</a>
    <li><a href="#ref-for-utf-8②②">8.1.1. UTF-8 decoder</a> <a href="#ref-for-utf-8②③">(2)</a>
    <li><a href="#ref-for-utf-8②④">8.1.2. UTF-8 encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-decoder">
   <b><a href="#utf-8-decoder">#utf-8-decoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-decoder">8.1.1. UTF-8 decoder</a> <a href="#ref-for-utf-8-decoder①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-code-point">
   <b><a href="#utf-8-code-point">#utf-8-code-point</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-code-point">8.1.1. UTF-8 decoder</a> <a href="#ref-for-utf-8-code-point①">(2)</a> <a href="#ref-for-utf-8-code-point②">(3)</a> <a href="#ref-for-utf-8-code-point③">(4)</a> <a href="#ref-for-utf-8-code-point④">(5)</a> <a href="#ref-for-utf-8-code-point⑤">(6)</a> <a href="#ref-for-utf-8-code-point⑥">(7)</a> <a href="#ref-for-utf-8-code-point⑦">(8)</a> <a href="#ref-for-utf-8-code-point⑧">(9)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-bytes-seen">
   <b><a href="#utf-8-bytes-seen">#utf-8-bytes-seen</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-bytes-seen">8.1.1. UTF-8 decoder</a> <a href="#ref-for-utf-8-bytes-seen①">(2)</a> <a href="#ref-for-utf-8-bytes-seen②">(3)</a> <a href="#ref-for-utf-8-bytes-seen③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-bytes-needed">
   <b><a href="#utf-8-bytes-needed">#utf-8-bytes-needed</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-bytes-needed">8.1.1. UTF-8 decoder</a> <a href="#ref-for-utf-8-bytes-needed①">(2)</a> <a href="#ref-for-utf-8-bytes-needed②">(3)</a> <a href="#ref-for-utf-8-bytes-needed③">(4)</a> <a href="#ref-for-utf-8-bytes-needed④">(5)</a> <a href="#ref-for-utf-8-bytes-needed⑤">(6)</a> <a href="#ref-for-utf-8-bytes-needed⑥">(7)</a> <a href="#ref-for-utf-8-bytes-needed⑦">(8)</a> <a href="#ref-for-utf-8-bytes-needed⑧">(9)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-lower-boundary">
   <b><a href="#utf-8-lower-boundary">#utf-8-lower-boundary</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-lower-boundary">8.1.1. UTF-8 decoder</a> <a href="#ref-for-utf-8-lower-boundary①">(2)</a> <a href="#ref-for-utf-8-lower-boundary②">(3)</a> <a href="#ref-for-utf-8-lower-boundary③">(4)</a> <a href="#ref-for-utf-8-lower-boundary④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-upper-boundary">
   <b><a href="#utf-8-upper-boundary">#utf-8-upper-boundary</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-upper-boundary">8.1.1. UTF-8 decoder</a> <a href="#ref-for-utf-8-upper-boundary①">(2)</a> <a href="#ref-for-utf-8-upper-boundary②">(3)</a> <a href="#ref-for-utf-8-upper-boundary③">(4)</a> <a href="#ref-for-utf-8-upper-boundary④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-8-encoder">
   <b><a href="#utf-8-encoder">#utf-8-encoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-8-encoder">7.4. Interface TextEncoder</a> <a href="#ref-for-utf-8-encoder①">(2)</a> <a href="#ref-for-utf-8-encoder②">(3)</a> <a href="#ref-for-utf-8-encoder③">(4)</a> <a href="#ref-for-utf-8-encoder④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="single-byte-encoding">
   <b><a href="#single-byte-encoding">#single-byte-encoding</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-single-byte-encoding">9. Legacy single-byte encodings</a> <a href="#ref-for-single-byte-encoding①">(2)</a> <a href="#ref-for-single-byte-encoding②">(3)</a>
    <li><a href="#ref-for-single-byte-encoding③">9.1. single-byte decoder</a>
    <li><a href="#ref-for-single-byte-encoding④">9.2. single-byte encoder</a>
    <li><a href="#ref-for-single-byte-encoding⑤">14.5. x-user-defined</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="index-single-byte">
   <b><a href="#index-single-byte">#index-single-byte</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-index-single-byte">5. Indexes</a>
    <li><a href="#ref-for-index-single-byte①">9.1. single-byte decoder</a>
    <li><a href="#ref-for-index-single-byte②">9.2. single-byte encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="ibm866">
   <b><a href="#ibm866">#ibm866</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-ibm866">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-2">
   <b><a href="#iso-8859-2">#iso-8859-2</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-2">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-3">
   <b><a href="#iso-8859-3">#iso-8859-3</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-3">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-4">
   <b><a href="#iso-8859-4">#iso-8859-4</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-4">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-5">
   <b><a href="#iso-8859-5">#iso-8859-5</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-5">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-6">
   <b><a href="#iso-8859-6">#iso-8859-6</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-6">4.2. Names and labels</a>
    <li><a href="#ref-for-iso-8859-6①">9. Legacy single-byte encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-7">
   <b><a href="#iso-8859-7">#iso-8859-7</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-7">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-8">
   <b><a href="#iso-8859-8">#iso-8859-8</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-8">4.2. Names and labels</a>
    <li><a href="#ref-for-iso-8859-8①">9. Legacy single-byte encodings</a> <a href="#ref-for-iso-8859-8②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-8-i">
   <b><a href="#iso-8859-8-i">#iso-8859-8-i</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-8-i">4.2. Names and labels</a>
    <li><a href="#ref-for-iso-8859-8-i①">9. Legacy single-byte encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-10">
   <b><a href="#iso-8859-10">#iso-8859-10</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-10">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-13">
   <b><a href="#iso-8859-13">#iso-8859-13</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-13">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-14">
   <b><a href="#iso-8859-14">#iso-8859-14</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-14">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-15">
   <b><a href="#iso-8859-15">#iso-8859-15</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-15">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-8859-16">
   <b><a href="#iso-8859-16">#iso-8859-16</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-8859-16">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="koi8-r">
   <b><a href="#koi8-r">#koi8-r</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-koi8-r">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="koi8-u">
   <b><a href="#koi8-u">#koi8-u</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-koi8-u">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="macintosh">
   <b><a href="#macintosh">#macintosh</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-macintosh">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-874">
   <b><a href="#windows-874">#windows-874</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-874">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1250">
   <b><a href="#windows-1250">#windows-1250</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1250">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1251">
   <b><a href="#windows-1251">#windows-1251</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1251">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1252">
   <b><a href="#windows-1252">#windows-1252</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1252">2. Security background</a>
    <li><a href="#ref-for-windows-1252①">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1253">
   <b><a href="#windows-1253">#windows-1253</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1253">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1254">
   <b><a href="#windows-1254">#windows-1254</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1254">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1255">
   <b><a href="#windows-1255">#windows-1255</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1255">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1256">
   <b><a href="#windows-1256">#windows-1256</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1256">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1257">
   <b><a href="#windows-1257">#windows-1257</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1257">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="windows-1258">
   <b><a href="#windows-1258">#windows-1258</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-windows-1258">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="x-mac-cyrillic">
   <b><a href="#x-mac-cyrillic">#x-mac-cyrillic</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-x-mac-cyrillic">4.2. Names and labels</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="single-byte-decoder">
   <b><a href="#single-byte-decoder">#single-byte-decoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-single-byte-decoder">9. Legacy single-byte encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="single-byte-encoder">
   <b><a href="#single-byte-encoder">#single-byte-encoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-single-byte-encoder">9. Legacy single-byte encodings</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="gbk">
   <b><a href="#gbk">#gbk</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-gbk">4.2. Names and labels</a>
    <li><a href="#ref-for-gbk①">10.1.1. GBK decoder</a>
    <li><a href="#ref-for-gbk②">10.1.2. GBK encoder</a> <a href="#ref-for-gbk③">(2)</a> <a href="#ref-for-gbk④">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="gb18030">
   <b><a href="#gb18030">#gb18030</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-gb18030">4.2. Names and labels</a>
    <li><a href="#ref-for-gb18030①">10.1.1. GBK decoder</a>
    <li><a href="#ref-for-gb18030②">10.1.2. GBK encoder</a> <a href="#ref-for-gb18030③">(2)</a>
    <li><a href="#ref-for-gb18030④">10.2.1. gb18030 decoder</a> <a href="#ref-for-gb18030⑤">(2)</a>
    <li><a href="#ref-for-gb18030⑥">10.2.2. gb18030 encoder</a> <a href="#ref-for-gb18030⑦">(2)</a>
    <li><a href="#ref-for-gb18030⑧">Implementation considerations</a> <a href="#ref-for-gb18030⑨">(2)</a> <a href="#ref-for-gb18030①⓪">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="gb18030-first">
   <b><a href="#gb18030-first">#gb18030-first</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-gb18030-first">10.2.1. gb18030 decoder</a> <a href="#ref-for-gb18030-first①">(2)</a> <a href="#ref-for-gb18030-first②">(3)</a> <a href="#ref-for-gb18030-first③">(4)</a> <a href="#ref-for-gb18030-first④">(5)</a> <a href="#ref-for-gb18030-first⑤">(6)</a> <a href="#ref-for-gb18030-first⑥">(7)</a> <a href="#ref-for-gb18030-first⑦">(8)</a> <a href="#ref-for-gb18030-first⑧">(9)</a> <a href="#ref-for-gb18030-first⑨">(10)</a> <a href="#ref-for-gb18030-first①⓪">(11)</a>
    <li><a href="#ref-for-gb18030-first①①">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="gb18030-second">
   <b><a href="#gb18030-second">#gb18030-second</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-gb18030-second">10.2.1. gb18030 decoder</a> <a href="#ref-for-gb18030-second①">(2)</a> <a href="#ref-for-gb18030-second②">(3)</a> <a href="#ref-for-gb18030-second③">(4)</a> <a href="#ref-for-gb18030-second④">(5)</a> <a href="#ref-for-gb18030-second⑤">(6)</a> <a href="#ref-for-gb18030-second⑥">(7)</a> <a href="#ref-for-gb18030-second⑦">(8)</a> <a href="#ref-for-gb18030-second⑧">(9)</a> <a href="#ref-for-gb18030-second⑨">(10)</a> <a href="#ref-for-gb18030-second①⓪">(11)</a>
    <li><a href="#ref-for-gb18030-second①①">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="gb18030-third">
   <b><a href="#gb18030-third">#gb18030-third</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-gb18030-third">10.2.1. gb18030 decoder</a> <a href="#ref-for-gb18030-third①">(2)</a> <a href="#ref-for-gb18030-third②">(3)</a> <a href="#ref-for-gb18030-third③">(4)</a> <a href="#ref-for-gb18030-third④">(5)</a> <a href="#ref-for-gb18030-third⑤">(6)</a> <a href="#ref-for-gb18030-third⑥">(7)</a> <a href="#ref-for-gb18030-third⑦">(8)</a> <a href="#ref-for-gb18030-third⑧">(9)</a>
    <li><a href="#ref-for-gb18030-third⑨">Implementation considerations</a> <a href="#ref-for-gb18030-third①⓪">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="gbk-flag">
   <b><a href="#gbk-flag">#gbk-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-gbk-flag">10.1.2. GBK encoder</a>
    <li><a href="#ref-for-gbk-flag①">10.2.2. gb18030 encoder</a> <a href="#ref-for-gbk-flag②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="big5">
   <b><a href="#big5">#big5</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-big5">4.2. Names and labels</a>
    <li><a href="#ref-for-big5①">11.1.1. Big5 decoder</a> <a href="#ref-for-big5②">(2)</a>
    <li><a href="#ref-for-big5③">11.1.2. Big5 encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="big5-lead">
   <b><a href="#big5-lead">#big5-lead</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-big5-lead">11.1.1. Big5 decoder</a> <a href="#ref-for-big5-lead①">(2)</a> <a href="#ref-for-big5-lead②">(3)</a> <a href="#ref-for-big5-lead③">(4)</a> <a href="#ref-for-big5-lead④">(5)</a> <a href="#ref-for-big5-lead⑤">(6)</a> <a href="#ref-for-big5-lead⑥">(7)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="euc-jp">
   <b><a href="#euc-jp">#euc-jp</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-euc-jp">4.2. Names and labels</a>
    <li><a href="#ref-for-euc-jp①">12.1.1. EUC-JP decoder</a> <a href="#ref-for-euc-jp②">(2)</a>
    <li><a href="#ref-for-euc-jp③">12.1.2. EUC-JP encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="euc-jp-decoder">
   <b><a href="#euc-jp-decoder">#euc-jp-decoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-euc-jp-decoder">5. Indexes</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="euc-jp-jis0212-flag">
   <b><a href="#euc-jp-jis0212-flag">#euc-jp-jis0212-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-euc-jp-jis0212-flag">12.1.1. EUC-JP decoder</a> <a href="#ref-for-euc-jp-jis0212-flag①">(2)</a> <a href="#ref-for-euc-jp-jis0212-flag②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="euc-jp-lead">
   <b><a href="#euc-jp-lead">#euc-jp-lead</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-euc-jp-lead">12.1.1. EUC-JP decoder</a> <a href="#ref-for-euc-jp-lead①">(2)</a> <a href="#ref-for-euc-jp-lead②">(3)</a> <a href="#ref-for-euc-jp-lead③">(4)</a> <a href="#ref-for-euc-jp-lead④">(5)</a> <a href="#ref-for-euc-jp-lead⑤">(6)</a> <a href="#ref-for-euc-jp-lead⑥">(7)</a> <a href="#ref-for-euc-jp-lead⑦">(8)</a> <a href="#ref-for-euc-jp-lead⑧">(9)</a> <a href="#ref-for-euc-jp-lead⑨">(10)</a> <a href="#ref-for-euc-jp-lead①⓪">(11)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp">
   <b><a href="#iso-2022-jp">#iso-2022-jp</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp">2. Security background</a>
    <li><a href="#ref-for-iso-2022-jp①">4.2. Names and labels</a>
    <li><a href="#ref-for-iso-2022-jp②">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp③">(2)</a>
    <li><a href="#ref-for-iso-2022-jp④">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-iso-2022-jp⑤">(2)</a>
    <li><a href="#ref-for-iso-2022-jp⑥">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-state">
   <b><a href="#iso-2022-jp-decoder-state">#iso-2022-jp-decoder-state</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-state">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp-decoder-state①">(2)</a> <a href="#ref-for-iso-2022-jp-decoder-state②">(3)</a> <a href="#ref-for-iso-2022-jp-decoder-state③">(4)</a> <a href="#ref-for-iso-2022-jp-decoder-state④">(5)</a> <a href="#ref-for-iso-2022-jp-decoder-state⑤">(6)</a> <a href="#ref-for-iso-2022-jp-decoder-state⑥">(7)</a> <a href="#ref-for-iso-2022-jp-decoder-state⑦">(8)</a> <a href="#ref-for-iso-2022-jp-decoder-state⑧">(9)</a> <a href="#ref-for-iso-2022-jp-decoder-state⑨">(10)</a> <a href="#ref-for-iso-2022-jp-decoder-state①⓪">(11)</a> <a href="#ref-for-iso-2022-jp-decoder-state①①">(12)</a> <a href="#ref-for-iso-2022-jp-decoder-state①②">(13)</a> <a href="#ref-for-iso-2022-jp-decoder-state①③">(14)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-output-state">
   <b><a href="#iso-2022-jp-decoder-output-state">#iso-2022-jp-decoder-output-state</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-output-state">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp-decoder-output-state①">(2)</a> <a href="#ref-for-iso-2022-jp-decoder-output-state②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-lead">
   <b><a href="#iso-2022-jp-lead">#iso-2022-jp-lead</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-lead">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp-lead①">(2)</a> <a href="#ref-for-iso-2022-jp-lead②">(3)</a> <a href="#ref-for-iso-2022-jp-lead③">(4)</a> <a href="#ref-for-iso-2022-jp-lead④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-output-flag">
   <b><a href="#iso-2022-jp-output-flag">#iso-2022-jp-output-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-output-flag">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp-output-flag①">(2)</a> <a href="#ref-for-iso-2022-jp-output-flag②">(3)</a> <a href="#ref-for-iso-2022-jp-output-flag③">(4)</a> <a href="#ref-for-iso-2022-jp-output-flag④">(5)</a> <a href="#ref-for-iso-2022-jp-output-flag⑤">(6)</a> <a href="#ref-for-iso-2022-jp-output-flag⑥">(7)</a> <a href="#ref-for-iso-2022-jp-output-flag⑦">(8)</a> <a href="#ref-for-iso-2022-jp-output-flag⑧">(9)</a> <a href="#ref-for-iso-2022-jp-output-flag⑨">(10)</a> <a href="#ref-for-iso-2022-jp-output-flag①⓪">(11)</a> <a href="#ref-for-iso-2022-jp-output-flag①①">(12)</a> <a href="#ref-for-iso-2022-jp-output-flag①②">(13)</a> <a href="#ref-for-iso-2022-jp-output-flag①③">(14)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-ascii">
   <b><a href="#iso-2022-jp-decoder-ascii">#iso-2022-jp-decoder-ascii</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-ascii">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp-decoder-ascii①">(2)</a> <a href="#ref-for-iso-2022-jp-decoder-ascii②">(3)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-roman">
   <b><a href="#iso-2022-jp-decoder-roman">#iso-2022-jp-decoder-roman</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-roman">12.2.1. ISO-2022-JP decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-katakana">
   <b><a href="#iso-2022-jp-decoder-katakana">#iso-2022-jp-decoder-katakana</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-katakana">12.2.1. ISO-2022-JP decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-lead-byte">
   <b><a href="#iso-2022-jp-decoder-lead-byte">#iso-2022-jp-decoder-lead-byte</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-lead-byte">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp-decoder-lead-byte①">(2)</a> <a href="#ref-for-iso-2022-jp-decoder-lead-byte②">(3)</a> <a href="#ref-for-iso-2022-jp-decoder-lead-byte③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-trail-byte">
   <b><a href="#iso-2022-jp-decoder-trail-byte">#iso-2022-jp-decoder-trail-byte</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-trail-byte">12.2.1. ISO-2022-JP decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-escape-start">
   <b><a href="#iso-2022-jp-decoder-escape-start">#iso-2022-jp-decoder-escape-start</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-escape-start">12.2.1. ISO-2022-JP decoder</a> <a href="#ref-for-iso-2022-jp-decoder-escape-start①">(2)</a> <a href="#ref-for-iso-2022-jp-decoder-escape-start②">(3)</a> <a href="#ref-for-iso-2022-jp-decoder-escape-start③">(4)</a> <a href="#ref-for-iso-2022-jp-decoder-escape-start④">(5)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-decoder-escape">
   <b><a href="#iso-2022-jp-decoder-escape">#iso-2022-jp-decoder-escape</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-decoder-escape">12.2.1. ISO-2022-JP decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-encoder">
   <b><a href="#iso-2022-jp-encoder">#iso-2022-jp-encoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-encoder">5. Indexes</a>
    <li><a href="#ref-for-iso-2022-jp-encoder①">12.2.2. ISO-2022-JP encoder</a>
    <li><a href="#ref-for-iso-2022-jp-encoder②">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-encoder-state">
   <b><a href="#iso-2022-jp-encoder-state">#iso-2022-jp-encoder-state</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-encoder-state">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-iso-2022-jp-encoder-state①">(2)</a> <a href="#ref-for-iso-2022-jp-encoder-state②">(3)</a> <a href="#ref-for-iso-2022-jp-encoder-state③">(4)</a> <a href="#ref-for-iso-2022-jp-encoder-state④">(5)</a> <a href="#ref-for-iso-2022-jp-encoder-state⑤">(6)</a> <a href="#ref-for-iso-2022-jp-encoder-state⑥">(7)</a> <a href="#ref-for-iso-2022-jp-encoder-state⑦">(8)</a> <a href="#ref-for-iso-2022-jp-encoder-state⑧">(9)</a> <a href="#ref-for-iso-2022-jp-encoder-state⑨">(10)</a> <a href="#ref-for-iso-2022-jp-encoder-state①⓪">(11)</a> <a href="#ref-for-iso-2022-jp-encoder-state①①">(12)</a>
    <li><a href="#ref-for-iso-2022-jp-encoder-state①②">Implementation considerations</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-encoder-ascii">
   <b><a href="#iso-2022-jp-encoder-ascii">#iso-2022-jp-encoder-ascii</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-encoder-ascii">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-iso-2022-jp-encoder-ascii①">(2)</a> <a href="#ref-for-iso-2022-jp-encoder-ascii②">(3)</a> <a href="#ref-for-iso-2022-jp-encoder-ascii③">(4)</a> <a href="#ref-for-iso-2022-jp-encoder-ascii④">(5)</a> <a href="#ref-for-iso-2022-jp-encoder-ascii⑤">(6)</a> <a href="#ref-for-iso-2022-jp-encoder-ascii⑥">(7)</a> <a href="#ref-for-iso-2022-jp-encoder-ascii⑦">(8)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-encoder-roman">
   <b><a href="#iso-2022-jp-encoder-roman">#iso-2022-jp-encoder-roman</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-encoder-roman">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-iso-2022-jp-encoder-roman①">(2)</a> <a href="#ref-for-iso-2022-jp-encoder-roman②">(3)</a> <a href="#ref-for-iso-2022-jp-encoder-roman③">(4)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="iso-2022-jp-encoder-jis0208">
   <b><a href="#iso-2022-jp-encoder-jis0208">#iso-2022-jp-encoder-jis0208</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-iso-2022-jp-encoder-jis0208">12.2.2. ISO-2022-JP encoder</a> <a href="#ref-for-iso-2022-jp-encoder-jis0208①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="shift_jis">
   <b><a href="#shift_jis">#shift_jis</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-shift_jis">2. Security background</a>
    <li><a href="#ref-for-shift_jis①">4.2. Names and labels</a>
    <li><a href="#ref-for-shift_jis②">5. Indexes</a>
    <li><a href="#ref-for-shift_jis③">12.3.1. Shift_JIS decoder</a> <a href="#ref-for-shift_jis④">(2)</a>
    <li><a href="#ref-for-shift_jis⑤">12.3.2. Shift_JIS encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="shift_jis-lead">
   <b><a href="#shift_jis-lead">#shift_jis-lead</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-shift_jis-lead">12.3.1. Shift_JIS decoder</a> <a href="#ref-for-shift_jis-lead①">(2)</a> <a href="#ref-for-shift_jis-lead②">(3)</a> <a href="#ref-for-shift_jis-lead③">(4)</a> <a href="#ref-for-shift_jis-lead④">(5)</a> <a href="#ref-for-shift_jis-lead⑤">(6)</a> <a href="#ref-for-shift_jis-lead⑥">(7)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="euc-kr">
   <b><a href="#euc-kr">#euc-kr</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-euc-kr">4.2. Names and labels</a>
    <li><a href="#ref-for-euc-kr①">13.1.1. EUC-KR decoder</a> <a href="#ref-for-euc-kr②">(2)</a>
    <li><a href="#ref-for-euc-kr③">13.1.2. EUC-KR encoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="euc-kr-lead">
   <b><a href="#euc-kr-lead">#euc-kr-lead</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-euc-kr-lead">13.1.1. EUC-KR decoder</a> <a href="#ref-for-euc-kr-lead①">(2)</a> <a href="#ref-for-euc-kr-lead②">(3)</a> <a href="#ref-for-euc-kr-lead③">(4)</a> <a href="#ref-for-euc-kr-lead④">(5)</a> <a href="#ref-for-euc-kr-lead⑤">(6)</a> <a href="#ref-for-euc-kr-lead⑥">(7)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="replacement">
   <b><a href="#replacement">#replacement</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-replacement">2. Security background</a>
    <li><a href="#ref-for-replacement①">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-replacement②">4.2. Names and labels</a>
    <li><a href="#ref-for-replacement③">4.3. Output encodings</a>
    <li><a href="#ref-for-replacement④">6. Hooks for standards</a>
    <li><a href="#ref-for-replacement⑤">7.2. Interface TextDecoder</a> <a href="#ref-for-replacement⑥">(2)</a>
    <li><a href="#ref-for-replacement⑦">7.6. Interface TextDecoderStream</a> <a href="#ref-for-replacement⑧">(2)</a>
    <li><a href="#ref-for-replacement⑨">14.1. replacement</a>
    <li><a href="#ref-for-replacement①⓪">14.1.1. replacement decoder</a> <a href="#ref-for-replacement①①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="replacement-error-returned-flag">
   <b><a href="#replacement-error-returned-flag">#replacement-error-returned-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-replacement-error-returned-flag">14.1.1. replacement decoder</a> <a href="#ref-for-replacement-error-returned-flag①">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="shared-utf-16-decoder">
   <b><a href="#shared-utf-16-decoder">#shared-utf-16-decoder</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-shared-utf-16-decoder">14.2.1. shared UTF-16 decoder</a> <a href="#ref-for-shared-utf-16-decoder①">(2)</a> <a href="#ref-for-shared-utf-16-decoder②">(3)</a>
    <li><a href="#ref-for-shared-utf-16-decoder③">14.3.1. UTF-16BE decoder</a>
    <li><a href="#ref-for-shared-utf-16-decoder④">14.4.1. UTF-16LE decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-16-lead-byte">
   <b><a href="#utf-16-lead-byte">#utf-16-lead-byte</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-16-lead-byte">14.2.1. shared UTF-16 decoder</a> <a href="#ref-for-utf-16-lead-byte①">(2)</a> <a href="#ref-for-utf-16-lead-byte②">(3)</a> <a href="#ref-for-utf-16-lead-byte③">(4)</a> <a href="#ref-for-utf-16-lead-byte④">(5)</a> <a href="#ref-for-utf-16-lead-byte⑤">(6)</a> <a href="#ref-for-utf-16-lead-byte⑥">(7)</a> <a href="#ref-for-utf-16-lead-byte⑦">(8)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-16-lead-surrogate">
   <b><a href="#utf-16-lead-surrogate">#utf-16-lead-surrogate</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-16-lead-surrogate">14.2.1. shared UTF-16 decoder</a> <a href="#ref-for-utf-16-lead-surrogate①">(2)</a> <a href="#ref-for-utf-16-lead-surrogate②">(3)</a> <a href="#ref-for-utf-16-lead-surrogate③">(4)</a> <a href="#ref-for-utf-16-lead-surrogate④">(5)</a> <a href="#ref-for-utf-16-lead-surrogate⑤">(6)</a> <a href="#ref-for-utf-16-lead-surrogate⑥">(7)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-16be-decoder-flag">
   <b><a href="#utf-16be-decoder-flag">#utf-16be-decoder-flag</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-16be-decoder-flag">14.2.1. shared UTF-16 decoder</a> <a href="#ref-for-utf-16be-decoder-flag①">(2)</a> <a href="#ref-for-utf-16be-decoder-flag②">(3)</a>
    <li><a href="#ref-for-utf-16be-decoder-flag③">14.3.1. UTF-16BE decoder</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-16be">
   <b><a href="#utf-16be">#utf-16be</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-16be">2. Security background</a>
    <li><a href="#ref-for-utf-16be①">4. Encodings</a> <a href="#ref-for-utf-16be②">(2)</a>
    <li><a href="#ref-for-utf-16be③">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-utf-16be④">4.2. Names and labels</a>
    <li><a href="#ref-for-utf-16be⑤">4.3. Output encodings</a>
    <li><a href="#ref-for-utf-16be⑥">6. Hooks for standards</a> <a href="#ref-for-utf-16be⑦">(2)</a>
    <li><a href="#ref-for-utf-16be⑧">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-utf-16be⑨">14.2. Common infrastructure for UTF-16BE and UTF-16LE</a>
    <li><a href="#ref-for-utf-16be①⓪">14.3.1. UTF-16BE decoder</a>
    <li><a href="#ref-for-utf-16be①①">15. Browser UI</a> <a href="#ref-for-utf-16be①②">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="utf-16le">
   <b><a href="#utf-16le">#utf-16le</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-utf-16le">2. Security background</a>
    <li><a href="#ref-for-utf-16le①">4. Encodings</a> <a href="#ref-for-utf-16le②">(2)</a>
    <li><a href="#ref-for-utf-16le③">4.1. Encoders and decoders</a>
    <li><a href="#ref-for-utf-16le④">4.2. Names and labels</a>
    <li><a href="#ref-for-utf-16le⑤">4.3. Output encodings</a>
    <li><a href="#ref-for-utf-16le⑥">6. Hooks for standards</a> <a href="#ref-for-utf-16le⑦">(2)</a>
    <li><a href="#ref-for-utf-16le⑧">7.1. Interface mixin TextDecoderCommon</a>
    <li><a href="#ref-for-utf-16le⑨">14.2. Common infrastructure for UTF-16BE and UTF-16LE</a>
    <li><a href="#ref-for-utf-16le①⓪">14.4. UTF-16LE</a>
    <li><a href="#ref-for-utf-16le①①">14.4.1. UTF-16LE decoder</a>
    <li><a href="#ref-for-utf-16le①②">15. Browser UI</a> <a href="#ref-for-utf-16le①③">(2)</a>
   </ul>
  </aside>
  <aside class="dfn-panel" data-for="x-user-defined">
   <b><a href="#x-user-defined">#x-user-defined</a></b><b>Referenced in:</b>
   <ul>
    <li><a href="#ref-for-x-user-defined">4.2. Names and labels</a>
    <li><a href="#ref-for-x-user-defined①">14.5.1. x-user-defined decoder</a>
    <li><a href="#ref-for-x-user-defined②">14.5.2. x-user-defined encoder</a>
   </ul>
  </aside>
<script>/* script-dfn-panel */

document.body.addEventListener("click", function(e) {
    var queryAll = function(sel) { return [].slice.call(document.querySelectorAll(sel)); }
    // Find the dfn element or panel, if any, that was clicked on.
    var el = e.target;
    var target;
    var hitALink = false;
    while(el.parentElement) {
        if(el.tagName == "A") {
            // Clicking on a link in a <dfn> shouldn't summon the panel
            hitALink = true;
        }
        if(el.classList.contains("dfn-paneled")) {
            target = "dfn";
            break;
        }
        if(el.classList.contains("dfn-panel")) {
            target = "dfn-panel";
            break;
        }
        el = el.parentElement;
    }
    if(target != "dfn-panel") {
        // Turn off any currently "on" or "activated" panels.
        queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(function(el){
            el.classList.remove("on");
            el.classList.remove("activated");
        });
    }
    if(target == "dfn" && !hitALink) {
        // open the panel
        var dfnPanel = document.querySelector(".dfn-panel[data-for='" + el.id + "']");
        if(dfnPanel) {
            dfnPanel.classList.add("on");
            var rect = el.getBoundingClientRect();
            dfnPanel.style.left = window.scrollX + rect.right + 5 + "px";
            dfnPanel.style.top = window.scrollY + rect.top + "px";
            var panelRect = dfnPanel.getBoundingClientRect();
            var panelWidth = panelRect.right - panelRect.left;
            if(panelRect.right > document.body.scrollWidth && (rect.left - (panelWidth + 5)) > 0) {
                // Reposition, because the panel is overflowing
                dfnPanel.style.left = window.scrollX + rect.left - (panelWidth + 5) + "px";
            }
        } else {
            console.log("Couldn't find .dfn-panel[data-for='" + el.id + "']");
        }
    } else if(target == "dfn-panel") {
        // Switch it to "activated" state, which pins it.
        el.classList.add("activated");
        el.style.left = null;
        el.style.top = null;
    }

});
</script>